From 3454e5b24b6d21f43769f55de5f86d9feeb6ad20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 14 May 2024 13:18:26 +0200 Subject: [PATCH 1/8] refactor: use assert_character() instead of as.character() --- R/attributes.R | 21 +++++++++++++-------- R/utils-assert-character.R | 5 +++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 R/utils-assert-character.R diff --git a/R/attributes.R b/R/attributes.R index 74f1197de89..8a23af79de1 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -282,7 +282,9 @@ graph_attr <- function(graph, name) { return(graph.attributes(graph)) } - .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[as.character(name)]] + assert_character(name) + + .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[name]] } @@ -384,8 +386,10 @@ vertex_attr <- function(graph, name, index = V(graph)) { } return(vertex.attributes(graph, index = index)) } + + assert_character(name) myattr <- - .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex)[[as.character(name)]] + .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex)[[name]] if (is_complete_iterator(index)) { return(myattr) } @@ -456,6 +460,7 @@ set_vertex_attr <- function(graph, name, index = V(graph), value) { i_set_vertex_attr <- function(graph, name, index = V(graph), value, check = TRUE) { ensure_igraph(graph) + assert_character(name) if (is.null(value)) { return(graph) @@ -470,7 +475,6 @@ i_set_vertex_attr <- function(graph, name, index = V(graph), value, check = TRUE if (!missing(index) && check) { index <- as_igraph_vs(graph, index) } - name <- as.character(name) vattrs <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex) @@ -594,7 +598,7 @@ edge_attr <- function(graph, name, index = E(graph)) { edge.attributes(graph, index = index) } } else { - name <- as.character(name) + assert_character(name) myattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge)[[name]] if (is_complete_iterator(index)) { myattr @@ -667,6 +671,7 @@ set_edge_attr <- function(graph, name, index = E(graph), value) { i_set_edge_attr <- function(graph, name, index = E(graph), value, check = TRUE) { ensure_igraph(graph) + assert_character(name) if (is.null(value)) { return(graph) @@ -680,7 +685,7 @@ i_set_edge_attr <- function(graph, name, index = E(graph), value, check = TRUE) complete <- is_complete_iterator(index) single <- is_single_index(index) - name <- as.character(name) + if (!missing(index) && check) { index <- as_igraph_es(graph, index) } @@ -853,8 +858,8 @@ edge_attr_names <- function(graph) { #' graph_attr_names(g2) delete_graph_attr <- function(graph, name) { ensure_igraph(graph) + assert_character(name) - name <- as.character(name) if (!name %in% graph_attr_names(graph)) { stop("No such graph attribute: ", name) } @@ -882,8 +887,8 @@ delete_graph_attr <- function(graph, name) { #' vertex_attr_names(g2) delete_vertex_attr <- function(graph, name) { ensure_igraph(graph) + assert_character(name) - name <- as.character(name) if (!name %in% vertex_attr_names(graph)) { stop("No such vertex attribute: ", name) } @@ -911,8 +916,8 @@ delete_vertex_attr <- function(graph, name) { #' edge_attr_names(g2) delete_edge_attr <- function(graph, name) { ensure_igraph(graph) + assert_character(name) - name <- as.character(name) if (!name %in% edge_attr_names(graph)) { stop("No such edge attribute: ", name) } diff --git a/R/utils-assert-character.R b/R/utils-assert-character.R new file mode 100644 index 00000000000..93095cef472 --- /dev/null +++ b/R/utils-assert-character.R @@ -0,0 +1,5 @@ +assert_character <- function(x, name = "name") { + if (!inherits(x, "character")) { + cli::cli_abort("{.arg {name}} must be a character, not {.obj_type_friendly {x}}.") + } +} From 242b69672def364fc9347be8fe88217ba16182be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 14 May 2024 13:20:18 +0200 Subject: [PATCH 2/8] refactor: use assert_character() in make.R --- R/make.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/make.R b/R/make.R index 43954d1061e..37c3bb94a2a 100644 --- a/R/make.R +++ b/R/make.R @@ -645,10 +645,11 @@ make_graph <- function(edges, ..., n = max(edges), isolates = NULL, } make_famous_graph <- function(name) { + assert_character(name) name <- gsub("\\s", "_", name) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_famous, as.character(name)) + res <- .Call(R_igraph_famous, name) if (igraph_opt("add.params")) { res$name <- capitalize(name) } From 42ca9252abcd503b23c10a7489801eb39aada279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Wed, 9 Apr 2025 13:46:12 +0200 Subject: [PATCH 3/8] assert more --- R/attributes.R | 346 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 275 insertions(+), 71 deletions(-) diff --git a/R/attributes.R b/R/attributes.R index 8a23af79de1..1a34d0e9d8c 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -1,4 +1,3 @@ - #' Set vertex attributes #' #' @description @@ -9,8 +8,13 @@ #' @inheritParams set_vertex_attr #' @keywords internal #' @export -set.vertex.attribute <- function(graph, name, index = V(graph), value) { # nocov start - lifecycle::deprecate_soft("2.0.0", "set.vertex.attribute()", "set_vertex_attr()") +set.vertex.attribute <- function(graph, name, index = V(graph), value) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "set.vertex.attribute()", + "set_vertex_attr()" + ) set_vertex_attr(graph = graph, name = name, index = index, value = value) } # nocov end @@ -24,8 +28,13 @@ set.vertex.attribute <- function(graph, name, index = V(graph), value) { # nocov #' @inheritParams set_graph_attr #' @keywords internal #' @export -set.graph.attribute <- function(graph, name, value) { # nocov start - lifecycle::deprecate_soft("2.0.0", "set.graph.attribute()", "set_graph_attr()") +set.graph.attribute <- function(graph, name, value) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "set.graph.attribute()", + "set_graph_attr()" + ) set_graph_attr(graph = graph, name = name, value = value) } # nocov end @@ -39,7 +48,8 @@ set.graph.attribute <- function(graph, name, value) { # nocov start #' @inheritParams set_edge_attr #' @keywords internal #' @export -set.edge.attribute <- function(graph, name, index = E(graph), value) { # nocov start +set.edge.attribute <- function(graph, name, index = E(graph), value) { + # nocov start lifecycle::deprecate_soft("2.0.0", "set.edge.attribute()", "set_edge_attr()") set_edge_attr(graph = graph, name = name, index = index, value = value) } # nocov end @@ -54,8 +64,13 @@ set.edge.attribute <- function(graph, name, index = E(graph), value) { # nocov s #' @inheritParams delete_vertex_attr #' @keywords internal #' @export -remove.vertex.attribute <- function(graph, name) { # nocov start - lifecycle::deprecate_soft("2.0.0", "remove.vertex.attribute()", "delete_vertex_attr()") +remove.vertex.attribute <- function(graph, name) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "remove.vertex.attribute()", + "delete_vertex_attr()" + ) delete_vertex_attr(graph = graph, name = name) } # nocov end @@ -69,8 +84,13 @@ remove.vertex.attribute <- function(graph, name) { # nocov start #' @inheritParams delete_graph_attr #' @keywords internal #' @export -remove.graph.attribute <- function(graph, name) { # nocov start - lifecycle::deprecate_soft("2.0.0", "remove.graph.attribute()", "delete_graph_attr()") +remove.graph.attribute <- function(graph, name) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "remove.graph.attribute()", + "delete_graph_attr()" + ) delete_graph_attr(graph = graph, name = name) } # nocov end @@ -84,8 +104,13 @@ remove.graph.attribute <- function(graph, name) { # nocov start #' @inheritParams delete_edge_attr #' @keywords internal #' @export -remove.edge.attribute <- function(graph, name) { # nocov start - lifecycle::deprecate_soft("2.0.0", "remove.edge.attribute()", "delete_edge_attr()") +remove.edge.attribute <- function(graph, name) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "remove.edge.attribute()", + "delete_edge_attr()" + ) delete_edge_attr(graph = graph, name = name) } # nocov end @@ -99,8 +124,13 @@ remove.edge.attribute <- function(graph, name) { # nocov start #' @inheritParams vertex_attr_names #' @keywords internal #' @export -list.vertex.attributes <- function(graph) { # nocov start - lifecycle::deprecate_soft("2.0.0", "list.vertex.attributes()", "vertex_attr_names()") +list.vertex.attributes <- function(graph) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "list.vertex.attributes()", + "vertex_attr_names()" + ) vertex_attr_names(graph = graph) } # nocov end @@ -114,8 +144,13 @@ list.vertex.attributes <- function(graph) { # nocov start #' @inheritParams graph_attr_names #' @keywords internal #' @export -list.graph.attributes <- function(graph) { # nocov start - lifecycle::deprecate_soft("2.0.0", "list.graph.attributes()", "graph_attr_names()") +list.graph.attributes <- function(graph) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "list.graph.attributes()", + "graph_attr_names()" + ) graph_attr_names(graph = graph) } # nocov end @@ -129,8 +164,13 @@ list.graph.attributes <- function(graph) { # nocov start #' @inheritParams edge_attr_names #' @keywords internal #' @export -list.edge.attributes <- function(graph) { # nocov start - lifecycle::deprecate_soft("2.0.0", "list.edge.attributes()", "edge_attr_names()") +list.edge.attributes <- function(graph) { + # nocov start + lifecycle::deprecate_soft( + "2.0.0", + "list.edge.attributes()", + "edge_attr_names()" + ) edge_attr_names(graph = graph) } # nocov end @@ -144,7 +184,8 @@ list.edge.attributes <- function(graph) { # nocov start #' @inheritParams is_weighted #' @keywords internal #' @export -is.weighted <- function(graph) { # nocov start +is.weighted <- function(graph) { + # nocov start lifecycle::deprecate_soft("2.0.0", "is.weighted()", "is_weighted()") is_weighted(graph = graph) } # nocov end @@ -159,7 +200,8 @@ is.weighted <- function(graph) { # nocov start #' @inheritParams is_named #' @keywords internal #' @export -is.named <- function(graph) { # nocov start +is.named <- function(graph) { + # nocov start lifecycle::deprecate_soft("2.0.0", "is.named()", "is_named()") is_named(graph = graph) } # nocov end @@ -174,7 +216,8 @@ is.named <- function(graph) { # nocov start #' @inheritParams is_bipartite #' @keywords internal #' @export -is.bipartite <- function(graph) { # nocov start +is.bipartite <- function(graph) { + # nocov start lifecycle::deprecate_soft("2.0.0", "is.bipartite()", "is_bipartite()") is_bipartite(graph = graph) } # nocov end @@ -189,7 +232,8 @@ is.bipartite <- function(graph) { # nocov start #' @inheritParams vertex_attr #' @keywords internal #' @export -get.vertex.attribute <- function(graph, name, index = V(graph)) { # nocov start +get.vertex.attribute <- function(graph, name, index = V(graph)) { + # nocov start lifecycle::deprecate_soft("2.0.0", "get.vertex.attribute()", "vertex_attr()") vertex_attr(graph = graph, name = name, index = index) } # nocov end @@ -204,7 +248,8 @@ get.vertex.attribute <- function(graph, name, index = V(graph)) { # nocov start #' @inheritParams graph_attr #' @keywords internal #' @export -get.graph.attribute <- function(graph, name) { # nocov start +get.graph.attribute <- function(graph, name) { + # nocov start lifecycle::deprecate_soft("2.0.0", "get.graph.attribute()", "graph_attr()") graph_attr(graph = graph, name = name) } # nocov end @@ -219,7 +264,8 @@ get.graph.attribute <- function(graph, name) { # nocov start #' @inheritParams edge_attr #' @keywords internal #' @export -get.edge.attribute <- function(graph, name, index = E(graph)) { # nocov start +get.edge.attribute <- function(graph, name, index = E(graph)) { + # nocov start lifecycle::deprecate_soft("2.0.0", "get.edge.attribute()", "edge_attr()") edge_attr(graph = graph, name = name, index = index) } # nocov end @@ -258,8 +304,6 @@ get.edge.attribute <- function(graph, name, index = E(graph)) { # nocov start ## e(graph)$weight[1:10] # get edge attribute ## - - #' Graph attributes of a graph #' #' @param graph Input graph. @@ -284,7 +328,9 @@ graph_attr <- function(graph, name) { assert_character(name) - .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[name]] + .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ + name + ]] } @@ -315,6 +361,7 @@ graph_attr <- function(graph, name) { if (missing(name)) { `graph.attributes<-`(graph, value) } else { + assert_character(name) set_graph_attr(graph, name, value) } } @@ -337,15 +384,29 @@ graph_attr <- function(graph, name) { #' g #' plot(g) set_graph_attr <- function(graph, name, value) { + assert_character(name) + ensure_igraph(graph) - .Call(R_igraph_mybracket3_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, name, value) + .Call( + R_igraph_mybracket3_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_graph, + name, + value + ) } #' @export graph.attributes <- function(graph) { ensure_igraph(graph) - .Call(R_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_graph) + .Call( + R_igraph_mybracket2_copy, + graph, + igraph_t_idx_attr, + igraph_attr_idx_graph + ) } #' @export @@ -353,7 +414,13 @@ graph.attributes <- function(graph) { ensure_igraph(graph) assert_named_list(value) - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, value) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_graph, + value + ) } @@ -389,13 +456,17 @@ vertex_attr <- function(graph, name, index = V(graph)) { assert_character(name) myattr <- - .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex)[[name]] + .Call( + R_igraph_mybracket2, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex + )[[name]] if (is_complete_iterator(index)) { return(myattr) } index <- as_igraph_vs(graph, index) myattr[index] - } #' Set one or more vertex attributes @@ -427,6 +498,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { if (missing(name)) { `vertex.attributes<-`(graph, index = index, value = value) } else { + assert_character(name) set_vertex_attr(graph, name = name, index = index, value = value) } } @@ -451,6 +523,8 @@ vertex_attr <- function(graph, name, index = V(graph)) { #' g #' plot(g) set_vertex_attr <- function(graph, name, index = V(graph), value) { + assert_character(name) + if (is_complete_iterator(index)) { i_set_vertex_attr(graph = graph, name = name, value = value, check = FALSE) } else { @@ -458,7 +532,13 @@ set_vertex_attr <- function(graph, name, index = V(graph), value) { } } -i_set_vertex_attr <- function(graph, name, index = V(graph), value, check = TRUE) { +i_set_vertex_attr <- function( + graph, + name, + index = V(graph), + value, + check = TRUE +) { ensure_igraph(graph) assert_character(name) @@ -476,7 +556,12 @@ i_set_vertex_attr <- function(graph, name, index = V(graph), value, check = TRUE index <- as_igraph_vs(graph, index) } - vattrs <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex) + vattrs <- .Call( + R_igraph_mybracket2, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex + ) complete <- is_complete_iterator(index) name_available <- (name %in% names(vattrs)) @@ -509,7 +594,13 @@ i_set_vertex_attr <- function(graph, name, index = V(graph), value, check = TRUE } } - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, vattrs) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex, + vattrs + ) } #' @export @@ -520,11 +611,17 @@ vertex.attributes <- function(graph, index = V(graph)) { index <- as_igraph_vs(graph, index) } - res <- .Call(R_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_vertex) + res <- .Call( + R_igraph_mybracket2_copy, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex + ) if (!missing(index)) { - index_is_natural_sequence <- (length(index) == vcount(graph) && all(index == V(graph))) - if (!index_is_natural_sequence) { + index_is_natural_sequence <- (length(index) == vcount(graph) && + all(index == V(graph))) + if (!index_is_natural_sequence) { for (i in seq_along(res)) { res[[i]] <- res[[i]][index] } @@ -552,8 +649,10 @@ vertex.attributes <- function(graph, index = V(graph)) { } } - if (!missing(index) && - (length(index) != vcount(graph) || any(index != V(graph)))) { + if ( + !missing(index) && + (length(index) != vcount(graph) || any(index != V(graph))) + ) { vs <- V(graph) for (i in seq_along(value)) { tmp <- value[[i]] @@ -564,7 +663,13 @@ vertex.attributes <- function(graph, index = V(graph)) { } } - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, value) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex, + value + ) } @@ -599,7 +704,12 @@ edge_attr <- function(graph, name, index = E(graph)) { } } else { assert_character(name) - myattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge)[[name]] + myattr <- .Call( + R_igraph_mybracket2, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge + )[[name]] if (is_complete_iterator(index)) { myattr } else { @@ -638,6 +748,7 @@ edge_attr <- function(graph, name, index = E(graph)) { if (missing(name)) { `edge.attributes<-`(graph, index = index, value = value) } else { + assert_character(name) set_edge_attr(graph, name = name, index = index, value = value) } } @@ -662,6 +773,7 @@ edge_attr <- function(graph, name, index = E(graph)) { #' g #' plot(g) set_edge_attr <- function(graph, name, index = E(graph), value) { + assert_character(name) if (is_complete_iterator(index)) { i_set_edge_attr(graph = graph, name = name, value = value, check = FALSE) } else { @@ -669,7 +781,13 @@ set_edge_attr <- function(graph, name, index = E(graph), value) { } } -i_set_edge_attr <- function(graph, name, index = E(graph), value, check = TRUE) { +i_set_edge_attr <- function( + graph, + name, + index = E(graph), + value, + check = TRUE +) { ensure_igraph(graph) assert_character(name) @@ -690,7 +808,12 @@ i_set_edge_attr <- function(graph, name, index = E(graph), value, check = TRUE) index <- as_igraph_es(graph, index) } - eattrs <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) + eattrs <- .Call( + R_igraph_mybracket2, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge + ) if (!complete && !(name %in% names(eattrs))) { eattrs[[name]] <- value[rep.int(NA_integer_, ecount(graph))] @@ -720,7 +843,13 @@ i_set_edge_attr <- function(graph, name, index = E(graph), value, check = TRUE) } } - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_edge, eattrs) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge, + eattrs + ) } #' @export @@ -731,10 +860,17 @@ edge.attributes <- function(graph, index = E(graph)) { index <- as_igraph_es(graph, index) } - res <- .Call(R_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_edge) - - if (!missing(index) && - (length(index) != ecount(graph) || any(index != E(graph)))) { + res <- .Call( + R_igraph_mybracket2_copy, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge + ) + + if ( + !missing(index) && + (length(index) != ecount(graph) || any(index != E(graph))) + ) { for (i in seq_along(res)) { res[[i]] <- res[[i]][index] } @@ -759,8 +895,10 @@ edge.attributes <- function(graph, index = E(graph)) { } } - if (!missing(index) && - (length(index) != ecount(graph) || any(index != E(graph)))) { + if ( + !missing(index) && + (length(index) != ecount(graph) || any(index != E(graph))) + ) { es <- E(graph) for (i in seq_along(value)) { tmp <- value[[i]] @@ -771,7 +909,13 @@ edge.attributes <- function(graph, index = E(graph)) { } } - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_edge, value) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge, + value + ) } #' List names of graph attributes @@ -788,7 +932,12 @@ edge.attributes <- function(graph, index = E(graph)) { #' graph_attr_names(g) graph_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call(R_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_graph) + res <- .Call( + R_igraph_mybracket2_names, + graph, + igraph_t_idx_attr, + igraph_attr_idx_graph + ) if (is.null(res)) { res <- character() } @@ -812,7 +961,12 @@ graph_attr_names <- function(graph) { vertex_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call(R_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_vertex) + res <- .Call( + R_igraph_mybracket2_names, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex + ) if (is.null(res)) { res <- character() @@ -835,7 +989,12 @@ vertex_attr_names <- function(graph) { #' plot(g) edge_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call(R_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_edge) + res <- .Call( + R_igraph_mybracket2_names, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge + ) if (is.null(res)) { res <- character() } @@ -864,10 +1023,21 @@ delete_graph_attr <- function(graph, name) { stop("No such graph attribute: ", name) } - gattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph) + gattr <- .Call( + R_igraph_mybracket2, + graph, + igraph_t_idx_attr, + igraph_attr_idx_graph + ) gattr[[name]] <- NULL - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, gattr) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_graph, + gattr + ) } #' Delete a vertex attribute @@ -893,10 +1063,21 @@ delete_vertex_attr <- function(graph, name) { stop("No such vertex attribute: ", name) } - vattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex) + vattr <- .Call( + R_igraph_mybracket2, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex + ) vattr[[name]] <- NULL - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, vattr) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_vertex, + vattr + ) } #' Delete an edge attribute @@ -922,16 +1103,25 @@ delete_edge_attr <- function(graph, name) { stop("No such edge attribute: ", name) } - eattr <- .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) + eattr <- .Call( + R_igraph_mybracket2, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge + ) eattr[[name]] <- NULL - .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_edge, eattr) + .Call( + R_igraph_mybracket2_set, + graph, + igraph_t_idx_attr, + igraph_attr_idx_edge, + eattr + ) } ############# - - #' Named graphs #' #' An igraph graph is named, if there is a symbolic name associated with its @@ -969,7 +1159,6 @@ is_named <- function(graph) { } - #' Weighted graphs #' #' In weighted graphs, a real number is assigned to each (directed or @@ -1023,9 +1212,13 @@ igraph.i.attribute.combination <- function(comb) { comb <- list(comb) } comb <- as.list(comb) - if (any(!sapply(comb, function(x) { - is.function(x) || (is.character(x) && length(x) == 1) - }))) { + if ( + any( + !sapply(comb, function(x) { + is.function(x) || (is.character(x) && length(x) == 1) + }) + ) + ) { stop("Attribute combination element must be a function or character scalar") } if (is.null(names(comb))) { @@ -1040,10 +1233,20 @@ igraph.i.attribute.combination <- function(comb) { } else { known <- data.frame( n = c( - "ignore", "sum", "prod", "min", "max", "random", - "first", "last", "mean", "median", "concat" + "ignore", + "sum", + "prod", + "min", + "max", + "random", + "first", + "last", + "mean", + "median", + "concat" ), - i = c(0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), stringsAsFactors = FALSE + i = c(0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), + stringsAsFactors = FALSE ) x <- pmatch(tolower(x), known[, 1]) if (is.na(x)) { @@ -1178,6 +1381,7 @@ NULL #' g$name <- "10-ring" #' g$name `$.igraph` <- function(x, name) { + assert_character(name) graph_attr(x, name) } @@ -1187,6 +1391,7 @@ NULL #' @name igraph-dollar #' @export `$<-.igraph` <- function(x, name, value) { + assert_character(name) set_graph_attr(x, name, value) } @@ -1202,7 +1407,6 @@ assert_named_list <- function(value) { } if (!rlang::is_named(value) || anyDuplicated(names(value)) > 0) { - rlang::abort(error_msg) } } From e8dc21fcb18dd309b5231d209d77fdb9c9a009b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Wed, 9 Apr 2025 14:06:15 +0200 Subject: [PATCH 4/8] chore: use rlang standalone files --- DESCRIPTION | 4 +- NAMESPACE | 1 + R/igraph-package.R | 2 +- R/import-standalone-obj-type.R | 365 ++++++++++++ R/import-standalone-types-check.R | 596 +++++++++++++++++++ R/utils-assert-character.R | 10 +- man/as.directed.Rd | 2 +- man/as_graphnel.Rd | 2 +- man/fit_hrg.Rd | 2 +- man/graph_from_graphnel.Rd | 2 +- man/layout_in_circle.Rd | 2 +- man/predict_edges.Rd | 2 +- man/sample_degseq.Rd | 4 +- man/sample_pref.Rd | 4 +- src/cpp11.cpp | 912 +++++++++++++++--------------- 15 files changed, 1437 insertions(+), 473 deletions(-) create mode 100644 R/import-standalone-obj-type.R create mode 100644 R/import-standalone-types-check.R diff --git a/DESCRIPTION b/DESCRIPTION index 976aef58be0..ab43bf74a85 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,7 @@ Imports: magrittr, Matrix, pkgconfig (>= 2.0.0), - rlang, + rlang (>= 1.1.0), stats, utils, vctrs @@ -71,5 +71,5 @@ Config/testthat/start-first: vs-es, scan, vs-operators, weakref, watts.strogatz.game Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2.9000 SystemRequirements: libxml2 (optional), glpk (>= 4.57, optional) diff --git a/NAMESPACE b/NAMESPACE index faf16778c99..1bab66bf2c1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -891,6 +891,7 @@ export(without_multiples) export(write.graph) export(write_graph) import(methods) +import(rlang) importFrom(grDevices,as.raster) importFrom(grDevices,col2rgb) importFrom(grDevices,dev.new) diff --git a/R/igraph-package.R b/R/igraph-package.R index a342371866d..dcdc00d8117 100644 --- a/R/igraph-package.R +++ b/R/igraph-package.R @@ -1,4 +1,3 @@ - #' @useDynLib igraph, .registration = TRUE #' @import methods ## usethis namespace: start @@ -10,6 +9,7 @@ #' @importFrom rlang inject #' @importFrom rlang warn #' @importFrom rlang %||% +#' @import rlang ## usethis namespace: end NULL diff --git a/R/import-standalone-obj-type.R b/R/import-standalone-obj-type.R new file mode 100644 index 00000000000..c582ba0847d --- /dev/null +++ b/R/import-standalone-obj-type.R @@ -0,0 +1,365 @@ +# Standalone file: do not edit by hand +# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-obj-type.R +# Generated by: usethis::use_standalone("r-lib/rlang", "obj-type") +# ---------------------------------------------------------------------- +# +# --- +# repo: r-lib/rlang +# file: standalone-obj-type.R +# last-updated: 2024-02-14 +# license: https://unlicense.org +# imports: rlang (>= 1.1.0) +# --- +# +# ## Changelog +# +# 2024-02-14: +# - `obj_type_friendly()` now works for S7 objects. +# +# 2023-05-01: +# - `obj_type_friendly()` now only displays the first class of S3 objects. +# +# 2023-03-30: +# - `stop_input_type()` now handles `I()` input literally in `arg`. +# +# 2022-10-04: +# - `obj_type_friendly(value = TRUE)` now shows numeric scalars +# literally. +# - `stop_friendly_type()` now takes `show_value`, passed to +# `obj_type_friendly()` as the `value` argument. +# +# 2022-10-03: +# - Added `allow_na` and `allow_null` arguments. +# - `NULL` is now backticked. +# - Better friendly type for infinities and `NaN`. +# +# 2022-09-16: +# - Unprefixed usage of rlang functions with `rlang::` to +# avoid onLoad issues when called from rlang (#1482). +# +# 2022-08-11: +# - Prefixed usage of rlang functions with `rlang::`. +# +# 2022-06-22: +# - `friendly_type_of()` is now `obj_type_friendly()`. +# - Added `obj_type_oo()`. +# +# 2021-12-20: +# - Added support for scalar values and empty vectors. +# - Added `stop_input_type()` +# +# 2021-06-30: +# - Added support for missing arguments. +# +# 2021-04-19: +# - Added support for matrices and arrays (#141). +# - Added documentation. +# - Added changelog. +# +# nocov start + +#' Return English-friendly type +#' @param x Any R object. +#' @param value Whether to describe the value of `x`. Special values +#' like `NA` or `""` are always described. +#' @param length Whether to mention the length of vectors and lists. +#' @return A string describing the type. Starts with an indefinite +#' article, e.g. "an integer vector". +#' @noRd +obj_type_friendly <- function(x, value = TRUE) { + if (is_missing(x)) { + return("absent") + } + + if (is.object(x)) { + if (inherits(x, "quosure")) { + type <- "quosure" + } else { + type <- class(x)[[1L]] + } + return(sprintf("a <%s> object", type)) + } + + if (!is_vector(x)) { + return(.rlang_as_friendly_type(typeof(x))) + } + + n_dim <- length(dim(x)) + + if (!n_dim) { + if (!is_list(x) && length(x) == 1) { + if (is_na(x)) { + return(switch( + typeof(x), + logical = "`NA`", + integer = "an integer `NA`", + double = if (is.nan(x)) { + "`NaN`" + } else { + "a numeric `NA`" + }, + complex = "a complex `NA`", + character = "a character `NA`", + .rlang_stop_unexpected_typeof(x) + )) + } + + show_infinites <- function(x) { + if (x > 0) { + "`Inf`" + } else { + "`-Inf`" + } + } + str_encode <- function(x, width = 30, ...) { + if (nchar(x) > width) { + x <- substr(x, 1, width - 3) + x <- paste0(x, "...") + } + encodeString(x, ...) + } + + if (value) { + if (is.numeric(x) && is.infinite(x)) { + return(show_infinites(x)) + } + + if (is.numeric(x) || is.complex(x)) { + number <- as.character(round(x, 2)) + what <- if (is.complex(x)) "the complex number" else "the number" + return(paste(what, number)) + } + + return(switch( + typeof(x), + logical = if (x) "`TRUE`" else "`FALSE`", + character = { + what <- if (nzchar(x)) "the string" else "the empty string" + paste(what, str_encode(x, quote = "\"")) + }, + raw = paste("the raw value", as.character(x)), + .rlang_stop_unexpected_typeof(x) + )) + } + + return(switch( + typeof(x), + logical = "a logical value", + integer = "an integer", + double = if (is.infinite(x)) show_infinites(x) else "a number", + complex = "a complex number", + character = if (nzchar(x)) "a string" else "\"\"", + raw = "a raw value", + .rlang_stop_unexpected_typeof(x) + )) + } + + if (length(x) == 0) { + return(switch( + typeof(x), + logical = "an empty logical vector", + integer = "an empty integer vector", + double = "an empty numeric vector", + complex = "an empty complex vector", + character = "an empty character vector", + raw = "an empty raw vector", + list = "an empty list", + .rlang_stop_unexpected_typeof(x) + )) + } + } + + vec_type_friendly(x) +} + +vec_type_friendly <- function(x, length = FALSE) { + if (!is_vector(x)) { + abort("`x` must be a vector.") + } + type <- typeof(x) + n_dim <- length(dim(x)) + + add_length <- function(type) { + if (length && !n_dim) { + paste0(type, sprintf(" of length %s", length(x))) + } else { + type + } + } + + if (type == "list") { + if (n_dim < 2) { + return(add_length("a list")) + } else if (is.data.frame(x)) { + return("a data frame") + } else if (n_dim == 2) { + return("a list matrix") + } else { + return("a list array") + } + } + + type <- switch( + type, + logical = "a logical %s", + integer = "an integer %s", + numeric = , + double = "a double %s", + complex = "a complex %s", + character = "a character %s", + raw = "a raw %s", + type = paste0("a ", type, " %s") + ) + + if (n_dim < 2) { + kind <- "vector" + } else if (n_dim == 2) { + kind <- "matrix" + } else { + kind <- "array" + } + out <- sprintf(type, kind) + + if (n_dim >= 2) { + out + } else { + add_length(out) + } +} + +.rlang_as_friendly_type <- function(type) { + switch( + type, + + list = "a list", + + NULL = "`NULL`", + environment = "an environment", + externalptr = "a pointer", + weakref = "a weak reference", + S4 = "an S4 object", + + name = , + symbol = "a symbol", + language = "a call", + pairlist = "a pairlist node", + expression = "an expression vector", + + char = "an internal string", + promise = "an internal promise", + ... = "an internal dots object", + any = "an internal `any` object", + bytecode = "an internal bytecode object", + + primitive = , + builtin = , + special = "a primitive function", + closure = "a function", + + type + ) +} + +.rlang_stop_unexpected_typeof <- function(x, call = caller_env()) { + abort( + sprintf("Unexpected type <%s>.", typeof(x)), + call = call + ) +} + +#' Return OO type +#' @param x Any R object. +#' @return One of `"bare"` (for non-OO objects), `"S3"`, `"S4"`, +#' `"R6"`, or `"S7"`. +#' @noRd +obj_type_oo <- function(x) { + if (!is.object(x)) { + return("bare") + } + + class <- inherits(x, c("R6", "S7_object"), which = TRUE) + + if (class[[1]]) { + "R6" + } else if (class[[2]]) { + "S7" + } else if (isS4(x)) { + "S4" + } else { + "S3" + } +} + +#' @param x The object type which does not conform to `what`. Its +#' `obj_type_friendly()` is taken and mentioned in the error message. +#' @param what The friendly expected type as a string. Can be a +#' character vector of expected types, in which case the error +#' message mentions all of them in an "or" enumeration. +#' @param show_value Passed to `value` argument of `obj_type_friendly()`. +#' @param ... Arguments passed to [abort()]. +#' @inheritParams args_error_context +#' @noRd +stop_input_type <- function( + x, + what, + ..., + allow_na = FALSE, + allow_null = FALSE, + show_value = TRUE, + arg = caller_arg(x), + call = caller_env() +) { + # From standalone-cli.R + cli <- env_get_list( + nms = c("format_arg", "format_code"), + last = topenv(), + default = function(x) sprintf("`%s`", x), + inherit = TRUE + ) + + if (allow_na) { + what <- c(what, cli$format_code("NA")) + } + if (allow_null) { + what <- c(what, cli$format_code("NULL")) + } + if (length(what)) { + what <- oxford_comma(what) + } + if (inherits(arg, "AsIs")) { + format_arg <- identity + } else { + format_arg <- cli$format_arg + } + + message <- sprintf( + "%s must be %s, not %s.", + format_arg(arg), + what, + obj_type_friendly(x, value = show_value) + ) + + abort(message, ..., call = call, arg = arg) +} + +oxford_comma <- function(chr, sep = ", ", final = "or") { + n <- length(chr) + + if (n < 2) { + return(chr) + } + + head <- chr[seq_len(n - 1)] + last <- chr[n] + + head <- paste(head, collapse = sep) + + # Write a or b. But a, b, or c. + if (n > 2) { + paste0(head, sep, final, " ", last) + } else { + paste0(head, " ", final, " ", last) + } +} + +# nocov end diff --git a/R/import-standalone-types-check.R b/R/import-standalone-types-check.R new file mode 100644 index 00000000000..5214a00eb39 --- /dev/null +++ b/R/import-standalone-types-check.R @@ -0,0 +1,596 @@ +# Standalone file: do not edit by hand +# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-types-check.R +# Generated by: usethis::use_standalone("r-lib/rlang", "types-check") +# ---------------------------------------------------------------------- +# +# --- +# repo: r-lib/rlang +# file: standalone-types-check.R +# last-updated: 2023-03-13 +# license: https://unlicense.org +# dependencies: standalone-obj-type.R +# imports: rlang (>= 1.1.0) +# --- +# +# ## Changelog +# +# 2024-08-15: +# - `check_character()` gains an `allow_na` argument (@martaalcalde, #1724) +# +# 2023-03-13: +# - Improved error messages of number checkers (@teunbrand) +# - Added `allow_infinite` argument to `check_number_whole()` (@mgirlich). +# - Added `check_data_frame()` (@mgirlich). +# +# 2023-03-07: +# - Added dependency on rlang (>= 1.1.0). +# +# 2023-02-15: +# - Added `check_logical()`. +# +# - `check_bool()`, `check_number_whole()`, and +# `check_number_decimal()` are now implemented in C. +# +# - For efficiency, `check_number_whole()` and +# `check_number_decimal()` now take a `NULL` default for `min` and +# `max`. This makes it possible to bypass unnecessary type-checking +# and comparisons in the default case of no bounds checks. +# +# 2022-10-07: +# - `check_number_whole()` and `_decimal()` no longer treat +# non-numeric types such as factors or dates as numbers. Numeric +# types are detected with `is.numeric()`. +# +# 2022-10-04: +# - Added `check_name()` that forbids the empty string. +# `check_string()` allows the empty string by default. +# +# 2022-09-28: +# - Removed `what` arguments. +# - Added `allow_na` and `allow_null` arguments. +# - Added `allow_decimal` and `allow_infinite` arguments. +# - Improved errors with absent arguments. +# +# +# 2022-09-16: +# - Unprefixed usage of rlang functions with `rlang::` to +# avoid onLoad issues when called from rlang (#1482). +# +# 2022-08-11: +# - Added changelog. +# +# nocov start + +# Scalars ----------------------------------------------------------------- + +.standalone_types_check_dot_call <- .Call + +check_bool <- function( + x, + ..., + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if ( + !missing(x) && + .standalone_types_check_dot_call( + ffi_standalone_is_bool_1.0.7, + x, + allow_na, + allow_null + ) + ) { + return(invisible(NULL)) + } + + stop_input_type( + x, + c("`TRUE`", "`FALSE`"), + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_string <- function( + x, + ..., + allow_empty = TRUE, + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + is_string <- .rlang_check_is_string( + x, + allow_empty = allow_empty, + allow_na = allow_na, + allow_null = allow_null + ) + if (is_string) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a single string", + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +.rlang_check_is_string <- function(x, allow_empty, allow_na, allow_null) { + if (is_string(x)) { + if (allow_empty || !is_string(x, "")) { + return(TRUE) + } + } + + if (allow_null && is_null(x)) { + return(TRUE) + } + + if (allow_na && (identical(x, NA) || identical(x, na_chr))) { + return(TRUE) + } + + FALSE +} + +check_name <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + is_string <- .rlang_check_is_string( + x, + allow_empty = FALSE, + allow_na = FALSE, + allow_null = allow_null + ) + if (is_string) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a valid name", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +IS_NUMBER_true <- 0 +IS_NUMBER_false <- 1 +IS_NUMBER_oob <- 2 + +check_number_decimal <- function( + x, + ..., + min = NULL, + max = NULL, + allow_infinite = TRUE, + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (missing(x)) { + exit_code <- IS_NUMBER_false + } else if ( + 0 == + (exit_code <- .standalone_types_check_dot_call( + ffi_standalone_check_number_1.0.7, + x, + allow_decimal = TRUE, + min, + max, + allow_infinite, + allow_na, + allow_null + )) + ) { + return(invisible(NULL)) + } + + .stop_not_number( + x, + ..., + exit_code = exit_code, + allow_decimal = TRUE, + min = min, + max = max, + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_number_whole <- function( + x, + ..., + min = NULL, + max = NULL, + allow_infinite = FALSE, + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (missing(x)) { + exit_code <- IS_NUMBER_false + } else if ( + 0 == + (exit_code <- .standalone_types_check_dot_call( + ffi_standalone_check_number_1.0.7, + x, + allow_decimal = FALSE, + min, + max, + allow_infinite, + allow_na, + allow_null + )) + ) { + return(invisible(NULL)) + } + + .stop_not_number( + x, + ..., + exit_code = exit_code, + allow_decimal = FALSE, + min = min, + max = max, + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +.stop_not_number <- function( + x, + ..., + exit_code, + allow_decimal, + min, + max, + allow_na, + allow_null, + arg, + call +) { + if (allow_decimal) { + what <- "a number" + } else { + what <- "a whole number" + } + + if (exit_code == IS_NUMBER_oob) { + min <- min %||% -Inf + max <- max %||% Inf + + if (min > -Inf && max < Inf) { + what <- sprintf("%s between %s and %s", what, min, max) + } else if (x < min) { + what <- sprintf("%s larger than or equal to %s", what, min) + } else if (x > max) { + what <- sprintf("%s smaller than or equal to %s", what, max) + } else { + abort("Unexpected state in OOB check", .internal = TRUE) + } + } + + stop_input_type( + x, + what, + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_symbol <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_symbol(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a symbol", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_arg <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_symbol(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "an argument name", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_call <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_call(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a defused call", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_environment <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_environment(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "an environment", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_function <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_function(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a function", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_closure <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_closure(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "an R function", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_formula <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_formula(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a formula", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + + +# Vectors ----------------------------------------------------------------- + +# TODO: Figure out what to do with logical `NA` and `allow_na = TRUE` + +check_character <- function( + x, + ..., + allow_na = TRUE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_character(x)) { + if (!allow_na && any(is.na(x))) { + abort( + sprintf("`%s` can't contain NA values.", arg), + arg = arg, + call = call + ) + } + + return(invisible(NULL)) + } + + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a character vector", + ..., + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_logical <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is_logical(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a logical vector", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_data_frame <- function( + x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env() +) { + if (!missing(x)) { + if (is.data.frame(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a data frame", + ..., + allow_null = allow_null, + arg = arg, + call = call + ) +} + +# nocov end diff --git a/R/utils-assert-character.R b/R/utils-assert-character.R index 93095cef472..adbec55d74e 100644 --- a/R/utils-assert-character.R +++ b/R/utils-assert-character.R @@ -1,5 +1,7 @@ -assert_character <- function(x, name = "name") { - if (!inherits(x, "character")) { - cli::cli_abort("{.arg {name}} must be a character, not {.obj_type_friendly {x}}.") - } +assert_character <- function(x, name = "name", call = rlang::caller_env()) { + check_string( + x, + arg = name, + call = call + ) } diff --git a/man/as.directed.Rd b/man/as.directed.Rd index ad2e7860fbe..b314969fecf 100644 --- a/man/as.directed.Rd +++ b/man/as.directed.Rd @@ -77,7 +77,7 @@ g3 <- make_ring(10, directed = TRUE, mutual = TRUE) E(g3)$weight <- seq_len(ecount(g3)) ug3 <- as.undirected(g3) print(ug3, e = TRUE) -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} x11(width = 10, height = 5) layout(rbind(1:2)) plot(g3, layout = layout_in_circle, edge.label = E(g3)$weight) diff --git a/man/as_graphnel.Rd b/man/as_graphnel.Rd index 3c5516ea359..7090ae9a3fc 100644 --- a/man/as_graphnel.Rd +++ b/man/as_graphnel.Rd @@ -25,7 +25,7 @@ vertex names in the graphNEL graph. Otherwise numeric igraph vertex ids will be used for this purpose. } \examples{ -\dontshow{if (rlang::is_installed("graph")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("graph")) withAutoprint(\{ # examplesIf} ## Undirected g <- make_ring(10) V(g)$name <- letters[1:10] diff --git a/man/fit_hrg.Rd b/man/fit_hrg.Rd index 51c385d4e71..29b1cb4b3c4 100644 --- a/man/fit_hrg.Rd +++ b/man/fit_hrg.Rd @@ -48,7 +48,7 @@ from a given HRG, if this is given in the \code{hrg()} argument and the \code{as.hclust()} provided in this package. } \examples{ -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## A graph with two dense groups g <- sample_gnp(10, p = 1 / 2) + sample_gnp(10, p = 1 / 2) diff --git a/man/graph_from_graphnel.Rd b/man/graph_from_graphnel.Rd index 378a7ffc2fd..c64473168a3 100644 --- a/man/graph_from_graphnel.Rd +++ b/man/graph_from_graphnel.Rd @@ -39,7 +39,7 @@ attributes of the multiple edges are lost: they are all replaced by the attributes of the first of the multiple edges. } \examples{ -\dontshow{if (rlang::is_installed("graph")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("graph")) withAutoprint(\{ # examplesIf} ## Undirected g <- make_ring(10) V(g)$name <- letters[1:10] diff --git a/man/layout_in_circle.Rd b/man/layout_in_circle.Rd index 3359d93f838..a9234984f09 100644 --- a/man/layout_in_circle.Rd +++ b/man/layout_in_circle.Rd @@ -29,7 +29,7 @@ If you want to order the vertices differently, then permute them using the \code{\link[=permute]{permute()}} function. } \examples{ -\dontshow{if (igraph:::has_glpk()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (igraph:::has_glpk()) withAutoprint(\{ # examplesIf} ## Place vertices on a circle, order them according to their ## community diff --git a/man/predict_edges.Rd b/man/predict_edges.Rd index b2c92ca5b7b..0c16c20bbb4 100644 --- a/man/predict_edges.Rd +++ b/man/predict_edges.Rd @@ -47,7 +47,7 @@ argument is set to \code{TRUE}. Otherwise a HRG is fitted to the graph first. } \examples{ -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## A graph with two dense groups g <- sample_gnp(10, p = 1 / 2) + sample_gnp(10, p = 1 / 2) diff --git a/man/sample_degseq.Rd b/man/sample_degseq.Rd index a62e8f621f0..c0195247c07 100644 --- a/man/sample_degseq.Rd +++ b/man/sample_degseq.Rd @@ -111,7 +111,7 @@ exp_vl_graph <- sample_degseq(exponential_degrees, method = "vl") all(degree(exp_vl_graph) == exponential_degrees) ## An example that does not work -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## withr::with_seed(11, { ## exponential_degrees <- sample(1:100, 100, replace = TRUE, prob = exp(-0.5 * (1:100))) ## }) @@ -156,7 +156,7 @@ powerlaw_vl_graph <- sample_degseq(powerlaw_degrees, method = "vl") all(degree(powerlaw_vl_graph) == powerlaw_degrees) ## An example that does not work -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## withr::with_seed(2, { ## powerlaw_degrees <- sample(1:100, 100, replace = TRUE, prob = (1:100)^-2) ## }) diff --git a/man/sample_pref.Rd b/man/sample_pref.Rd index 93b65bad52a..64d759fe8ba 100644 --- a/man/sample_pref.Rd +++ b/man/sample_pref.Rd @@ -85,7 +85,7 @@ The types of the generated vertices can be retrieved from the pf <- matrix(c(1, 0, 0, 1), nrow = 2) g <- sample_pref(20, 2, pref.matrix = pf) -\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) withAutoprint(\{ # examplesIf} # example code tkplot(g, layout = layout_with_fr) @@ -93,7 +93,7 @@ tkplot(g, layout = layout_with_fr) pf <- matrix(c(0, 1, 0, 0), nrow = 2) g <- sample_asym_pref(20, 2, pref.matrix = pf) -\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) withAutoprint(\{ # examplesIf} tkplot(g, layout = layout_in_circle) \dontshow{\}) # examplesIf} } diff --git a/src/cpp11.cpp b/src/cpp11.cpp index ef691f87be1..19b694ac205 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -22,463 +22,463 @@ extern "C" SEXP _igraph_getsphere(SEXP spos, SEXP sradius, SEXP scolor, SEXP lig extern "C" { /* .Call calls */ -extern SEXP R_igraph_add_edges(void *, void *); -extern SEXP R_igraph_add_edges_manual(void *, void *); -extern SEXP R_igraph_add_env(void *); -extern SEXP R_igraph_add_myid_to_env(void *); -extern SEXP R_igraph_add_version_to_env(void *); -extern SEXP R_igraph_add_vertices(void *, void *); -extern SEXP R_igraph_address(void *); -extern SEXP R_igraph_adhesion(void *, void *); -extern SEXP R_igraph_adjacency(void *, void *, void *); -extern SEXP R_igraph_adjacency_spectral_embedding(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_adjacent_triangles(void *, void *); -extern SEXP R_igraph_adjacent_vertices(void *, void *, void *); -extern SEXP R_igraph_adjlist(void *, void *, void *); -extern SEXP R_igraph_all_minimal_st_separators(void *); -extern SEXP R_igraph_all_st_cuts(void *, void *, void *); -extern SEXP R_igraph_all_st_mincuts(void *, void *, void *, void *); -extern SEXP R_igraph_are_adjacent(void *, void *, void *); -extern SEXP R_igraph_arpack(void *, void *, void *, void *, void *); -extern SEXP R_igraph_arpack_unpack_complex(void *, void *, void *); -extern SEXP R_igraph_articulation_points(void *); -extern SEXP R_igraph_assortativity(void *, void *, void *, void *, void *); -extern SEXP R_igraph_assortativity_degree(void *, void *); -extern SEXP R_igraph_assortativity_nominal(void *, void *, void *, void *); -extern SEXP R_igraph_asymmetric_preference_game(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_atlas(void *); -extern SEXP R_igraph_authority_score(void *, void *, void *, void *); -extern SEXP R_igraph_automorphism_group(void *, void *, void *); -extern SEXP R_igraph_average_local_efficiency(void *, void *, void *, void *); -extern SEXP R_igraph_average_path_length_dijkstra(void *, void *, void *, void *); -extern SEXP R_igraph_avg_nearest_neighbor_degree(void *, void *, void *, void *, void *); -extern SEXP R_igraph_barabasi_aging_game(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_barabasi_game(void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_betweenness_cutoff(void *, void *, void *, void *, void *); -extern SEXP R_igraph_betweenness_subset(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_bfs(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_bfs_simple(void *, void *, void *); -extern SEXP R_igraph_biadjacency(void *, void *, void *, void *); -extern SEXP R_igraph_bibcoupling(void *, void *); -extern SEXP R_igraph_biconnected_components(void *); -extern SEXP R_igraph_bipartite_game(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_bipartite_game_gnm(void *, void *, void *, void *, void *); -extern SEXP R_igraph_bipartite_game_gnp(void *, void *, void *, void *, void *); -extern SEXP R_igraph_bipartite_projection(void *, void *, void *, void *); -extern SEXP R_igraph_bipartite_projection_size(void *, void *); -extern SEXP R_igraph_bridges(void *); -extern SEXP R_igraph_callaway_traits_game(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_canonical_permutation(void *, void *, void *); -extern SEXP R_igraph_centralization(void *, void *, void *); -extern SEXP R_igraph_centralization_betweenness(void *, void *, void *); -extern SEXP R_igraph_centralization_betweenness_tmax(void *, void *, void *); -extern SEXP R_igraph_centralization_closeness(void *, void *, void *); -extern SEXP R_igraph_centralization_closeness_tmax(void *, void *, void *); -extern SEXP R_igraph_centralization_degree(void *, void *, void *, void *); -extern SEXP R_igraph_centralization_degree_tmax(void *, void *, void *, void *); -extern SEXP R_igraph_centralization_eigenvector_centrality(void *, void *, void *, void *, void *); -extern SEXP R_igraph_centralization_eigenvector_centrality_tmax(void *, void *, void *, void *); -extern SEXP R_igraph_circulant(void *, void *, void *); -extern SEXP R_igraph_cited_type_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_citing_cited_type_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_clique_number(void *); -extern SEXP R_igraph_clique_size_hist(void *, void *, void *); -extern SEXP R_igraph_cliques(void *, void *, void *); -extern SEXP R_igraph_closeness_cutoff(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_cocitation(void *, void *); -extern SEXP R_igraph_cohesion(void *, void *); -extern SEXP R_igraph_cohesive_blocks(void *); -extern SEXP R_igraph_community_edge_betweenness(void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_community_fastgreedy(void *, void *, void *, void *, void *); -extern SEXP R_igraph_community_fluid_communities(void *, void *); -extern SEXP R_igraph_community_infomap(void *, void *, void *, void *); -extern SEXP R_igraph_community_label_propagation(void *, void *, void *, void *, void *); -extern SEXP R_igraph_community_leading_eigenvector(void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_community_leiden(void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_community_multilevel(void *, void *, void *); -extern SEXP R_igraph_community_optimal_modularity(void *, void *); -extern SEXP R_igraph_community_to_membership2(void *, void *, void *); -extern SEXP R_igraph_compare_communities(void *, void *, void *); -extern SEXP R_igraph_complementer(void *, void *); -extern SEXP R_igraph_compose(void *, void *, void *); -extern SEXP R_igraph_connect_neighborhood(void *, void *, void *); -extern SEXP R_igraph_connected_components(void *, void *); -extern SEXP R_igraph_constraint(void *, void *, void *); -extern SEXP R_igraph_contract_vertices(void *, void *, void *); -extern SEXP R_igraph_convex_hull(void *); -extern SEXP R_igraph_copy(void *); -extern SEXP R_igraph_copy_env(void *); -extern SEXP R_igraph_copy_from(void *); -extern SEXP R_igraph_copy_to(void *); -extern SEXP R_igraph_coreness(void *, void *); -extern SEXP R_igraph_correlated_game(void *, void *, void *, void *); -extern SEXP R_igraph_correlated_pair_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_count_automorphisms(void *, void *, void *); -extern SEXP R_igraph_count_isomorphisms_vf2(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_count_multiple(void *, void *); -extern SEXP R_igraph_count_subisomorphisms_vf2(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_create(void *, void *, void *); -extern SEXP R_igraph_create_bipartite(void *, void *, void *); -extern SEXP R_igraph_de_bruijn(void *, void *); -extern SEXP R_igraph_decompose(void *, void *, void *, void *); -extern SEXP R_igraph_degree(void *, void *, void *, void *); -extern SEXP R_igraph_degree_correlation_vector(void *, void *, void *, void *, void *); -extern SEXP R_igraph_degree_sequence_game(void *, void *, void *); -extern SEXP R_igraph_delete_edges(void *, void *); -extern SEXP R_igraph_delete_vertices(void *, void *); -extern SEXP R_igraph_delete_vertices_idx(void *, void *); -extern SEXP R_igraph_density(void *, void *); -extern SEXP R_igraph_deterministic_optimal_imitation(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_dfs(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_diameter(void *, void *, void *, void *); -extern SEXP R_igraph_difference(void *, void *); -extern SEXP R_igraph_dim_select(void *); -extern SEXP R_igraph_disjoint_union(void *); -extern SEXP R_igraph_distances(void *, void *, void *, void *); -extern SEXP R_igraph_distances_bellman_ford(void *, void *, void *, void *, void *); -extern SEXP R_igraph_distances_cutoff(void *, void *, void *, void *, void *); -extern SEXP R_igraph_distances_dijkstra(void *, void *, void *, void *, void *); -extern SEXP R_igraph_distances_dijkstra_cutoff(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_distances_floyd_warshall(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_distances_johnson(void *, void *, void *, void *); -extern SEXP R_igraph_diversity(void *, void *, void *); -extern SEXP R_igraph_dominator_tree(void *, void *, void *); -extern SEXP R_igraph_dot_product_game(void *, void *); -extern SEXP R_igraph_dyad_census(void *); -extern SEXP R_igraph_ecc(void *, void *, void *, void *, void *); -extern SEXP R_igraph_eccentricity_dijkstra(void *, void *, void *, void *); -extern SEXP R_igraph_ecount(void *); -extern SEXP R_igraph_edge_betweenness_cutoff(void *, void *, void *, void *); -extern SEXP R_igraph_edge_betweenness_subset(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_edge_connectivity(void *, void *); -extern SEXP R_igraph_edge_disjoint_paths(void *, void *, void *); -extern SEXP R_igraph_edges(void *, void *); -extern SEXP R_igraph_eigen_adjacency(void *, void *, void *, void *); -extern SEXP R_igraph_eigenvector_centrality(void *, void *, void *, void *, void *); -extern SEXP R_igraph_empty(void *, void *); -extern SEXP R_igraph_erdos_renyi_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_es_adj(void *, void *, void *, void *); -extern SEXP R_igraph_es_pairs(void *, void *, void *); -extern SEXP R_igraph_es_path(void *, void *, void *); -extern SEXP R_igraph_establishment_game(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_eulerian_cycle(void *); -extern SEXP R_igraph_eulerian_path(void *); -extern SEXP R_igraph_even_tarjan_reduction(void *); -extern SEXP R_igraph_extended_chordal_ring(void *, void *, void *); -extern SEXP R_igraph_famous(void *); -extern SEXP R_igraph_farthest_points(void *, void *, void *, void *); -extern SEXP R_igraph_feedback_arc_set(void *, void *, void *); +extern SEXP R_igraph_add_edges(SEXP, SEXP); +extern SEXP R_igraph_add_edges_manual(SEXP, SEXP); +extern SEXP R_igraph_add_env(SEXP); +extern SEXP R_igraph_add_myid_to_env(SEXP); +extern SEXP R_igraph_add_version_to_env(SEXP); +extern SEXP R_igraph_add_vertices(SEXP, SEXP); +extern SEXP R_igraph_address(SEXP); +extern SEXP R_igraph_adhesion(SEXP, SEXP); +extern SEXP R_igraph_adjacency(SEXP, SEXP, SEXP); +extern SEXP R_igraph_adjacency_spectral_embedding(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_adjacent_triangles(SEXP, SEXP); +extern SEXP R_igraph_adjacent_vertices(SEXP, SEXP, SEXP); +extern SEXP R_igraph_adjlist(SEXP, SEXP, SEXP); +extern SEXP R_igraph_all_minimal_st_separators(SEXP); +extern SEXP R_igraph_all_st_cuts(SEXP, SEXP, SEXP); +extern SEXP R_igraph_all_st_mincuts(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_are_adjacent(SEXP, SEXP, SEXP); +extern SEXP R_igraph_arpack(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_arpack_unpack_complex(SEXP, SEXP, SEXP); +extern SEXP R_igraph_articulation_points(SEXP); +extern SEXP R_igraph_assortativity(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_assortativity_degree(SEXP, SEXP); +extern SEXP R_igraph_assortativity_nominal(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_asymmetric_preference_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_atlas(SEXP); +extern SEXP R_igraph_authority_score(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_automorphism_group(SEXP, SEXP, SEXP); +extern SEXP R_igraph_average_local_efficiency(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_average_path_length_dijkstra(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_avg_nearest_neighbor_degree(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_barabasi_aging_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_barabasi_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_betweenness_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_betweenness_subset(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_bfs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_bfs_simple(SEXP, SEXP, SEXP); +extern SEXP R_igraph_biadjacency(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_bibcoupling(SEXP, SEXP); +extern SEXP R_igraph_biconnected_components(SEXP); +extern SEXP R_igraph_bipartite_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_bipartite_game_gnm(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_bipartite_game_gnp(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_bipartite_projection(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_bipartite_projection_size(SEXP, SEXP); +extern SEXP R_igraph_bridges(SEXP); +extern SEXP R_igraph_callaway_traits_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_canonical_permutation(SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization(SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_betweenness(SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_betweenness_tmax(SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_closeness(SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_closeness_tmax(SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_degree(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_degree_tmax(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_eigenvector_centrality(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_centralization_eigenvector_centrality_tmax(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_circulant(SEXP, SEXP, SEXP); +extern SEXP R_igraph_cited_type_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_citing_cited_type_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_clique_number(SEXP); +extern SEXP R_igraph_clique_size_hist(SEXP, SEXP, SEXP); +extern SEXP R_igraph_cliques(SEXP, SEXP, SEXP); +extern SEXP R_igraph_closeness_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_cocitation(SEXP, SEXP); +extern SEXP R_igraph_cohesion(SEXP, SEXP); +extern SEXP R_igraph_cohesive_blocks(SEXP); +extern SEXP R_igraph_community_edge_betweenness(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_community_fastgreedy(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_community_fluid_communities(SEXP, SEXP); +extern SEXP R_igraph_community_infomap(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_community_label_propagation(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_community_leading_eigenvector(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_community_leiden(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_community_multilevel(SEXP, SEXP, SEXP); +extern SEXP R_igraph_community_optimal_modularity(SEXP, SEXP); +extern SEXP R_igraph_community_to_membership2(SEXP, SEXP, SEXP); +extern SEXP R_igraph_compare_communities(SEXP, SEXP, SEXP); +extern SEXP R_igraph_complementer(SEXP, SEXP); +extern SEXP R_igraph_compose(SEXP, SEXP, SEXP); +extern SEXP R_igraph_connect_neighborhood(SEXP, SEXP, SEXP); +extern SEXP R_igraph_connected_components(SEXP, SEXP); +extern SEXP R_igraph_constraint(SEXP, SEXP, SEXP); +extern SEXP R_igraph_contract_vertices(SEXP, SEXP, SEXP); +extern SEXP R_igraph_convex_hull(SEXP); +extern SEXP R_igraph_copy(SEXP); +extern SEXP R_igraph_copy_env(SEXP); +extern SEXP R_igraph_copy_from(SEXP); +extern SEXP R_igraph_copy_to(SEXP); +extern SEXP R_igraph_coreness(SEXP, SEXP); +extern SEXP R_igraph_correlated_game(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_correlated_pair_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_count_automorphisms(SEXP, SEXP, SEXP); +extern SEXP R_igraph_count_isomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_count_multiple(SEXP, SEXP); +extern SEXP R_igraph_count_subisomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_create(SEXP, SEXP, SEXP); +extern SEXP R_igraph_create_bipartite(SEXP, SEXP, SEXP); +extern SEXP R_igraph_de_bruijn(SEXP, SEXP); +extern SEXP R_igraph_decompose(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_degree(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_degree_correlation_vector(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_degree_sequence_game(SEXP, SEXP, SEXP); +extern SEXP R_igraph_delete_edges(SEXP, SEXP); +extern SEXP R_igraph_delete_vertices(SEXP, SEXP); +extern SEXP R_igraph_delete_vertices_idx(SEXP, SEXP); +extern SEXP R_igraph_density(SEXP, SEXP); +extern SEXP R_igraph_deterministic_optimal_imitation(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_dfs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_diameter(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_difference(SEXP, SEXP); +extern SEXP R_igraph_dim_select(SEXP); +extern SEXP R_igraph_disjoint_union(SEXP); +extern SEXP R_igraph_distances(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_bellman_ford(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_dijkstra_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_floyd_warshall(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_johnson(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_diversity(SEXP, SEXP, SEXP); +extern SEXP R_igraph_dominator_tree(SEXP, SEXP, SEXP); +extern SEXP R_igraph_dot_product_game(SEXP, SEXP); +extern SEXP R_igraph_dyad_census(SEXP); +extern SEXP R_igraph_ecc(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_eccentricity_dijkstra(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_ecount(SEXP); +extern SEXP R_igraph_edge_betweenness_cutoff(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_edge_betweenness_subset(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_edge_connectivity(SEXP, SEXP); +extern SEXP R_igraph_edge_disjoint_paths(SEXP, SEXP, SEXP); +extern SEXP R_igraph_edges(SEXP, SEXP); +extern SEXP R_igraph_eigen_adjacency(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_eigenvector_centrality(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_empty(SEXP, SEXP); +extern SEXP R_igraph_erdos_renyi_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_es_adj(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_es_pairs(SEXP, SEXP, SEXP); +extern SEXP R_igraph_es_path(SEXP, SEXP, SEXP); +extern SEXP R_igraph_establishment_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_eulerian_cycle(SEXP); +extern SEXP R_igraph_eulerian_path(SEXP); +extern SEXP R_igraph_even_tarjan_reduction(SEXP); +extern SEXP R_igraph_extended_chordal_ring(SEXP, SEXP, SEXP); +extern SEXP R_igraph_famous(SEXP); +extern SEXP R_igraph_farthest_points(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_feedback_arc_set(SEXP, SEXP, SEXP); extern SEXP R_igraph_finalizer(void); -extern SEXP R_igraph_forest_fire_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_from_hrg_dendrogram(void *); -extern SEXP R_igraph_from_prufer(void *); -extern SEXP R_igraph_full(void *, void *, void *); -extern SEXP R_igraph_full_bipartite(void *, void *, void *, void *); -extern SEXP R_igraph_full_citation(void *, void *); -extern SEXP R_igraph_full_multipartite(void *, void *, void *); -extern SEXP R_igraph_fundamental_cycles(void *, void *, void *, void *); -extern SEXP R_igraph_generalized_petersen(void *, void *); -extern SEXP R_igraph_get_adjacency(void *, void *, void *, void *); -extern SEXP R_igraph_get_adjedgelist(void *, void *, void *); -extern SEXP R_igraph_get_adjlist(void *, void *, void *, void *); -extern SEXP R_igraph_get_all_eids_between(void *, void *, void *, void *); -extern SEXP R_igraph_get_all_shortest_paths(void *, void *, void *, void *); -extern SEXP R_igraph_get_all_shortest_paths_dijkstra(void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_all_simple_paths(void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_all_simple_paths_pp(void *); -extern SEXP R_igraph_get_attr_mode(void *, void *); -extern SEXP R_igraph_get_biadjacency(void *, void *); -extern SEXP R_igraph_get_diameter(void *, void *, void *, void *); -extern SEXP R_igraph_get_edge(void *, void *); -extern SEXP R_igraph_get_edgelist(void *, void *); -extern SEXP R_igraph_get_eids(void *, void *, void *, void *); -extern SEXP R_igraph_get_graph_id(void *); -extern SEXP R_igraph_get_isomorphisms_vf2(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_k_shortest_paths(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_laplacian(void *, void *, void *, void *); -extern SEXP R_igraph_get_laplacian_sparse(void *, void *, void *, void *); -extern SEXP R_igraph_get_shortest_path(void *, void *, void *, void *); -extern SEXP R_igraph_get_shortest_path_bellman_ford(void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_shortest_path_dijkstra(void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_shortest_paths(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_stochastic(void *, void *, void *); -extern SEXP R_igraph_get_stochastic_sparse(void *, void *, void *); -extern SEXP R_igraph_get_subisomorphisms_vf2(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_widest_path(void *, void *, void *, void *, void *); -extern SEXP R_igraph_get_widest_paths(void *, void *, void *, void *, void *); -extern SEXP R_igraph_girth(void *, void *); -extern SEXP R_igraph_global_efficiency(void *, void *, void *); -extern SEXP R_igraph_gomory_hu_tree(void *, void *); -extern SEXP R_igraph_graph_center_dijkstra(void *, void *, void *); -extern SEXP R_igraph_graph_count(void *, void *); -extern SEXP R_igraph_graph_power(void *, void *, void *); -extern SEXP R_igraph_graph_version(void *); -extern SEXP R_igraph_graphlets(void *, void *, void *); -extern SEXP R_igraph_graphlets_candidate_basis(void *, void *); -extern SEXP R_igraph_graphlets_project(void *, void *, void *, void *, void *); -extern SEXP R_igraph_grg_game(void *, void *, void *, void *); -extern SEXP R_igraph_growing_random_game(void *, void *, void *, void *); -extern SEXP R_igraph_harmonic_centrality_cutoff(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_has_loop(void *); -extern SEXP R_igraph_has_multiple(void *); -extern SEXP R_igraph_has_mutual(void *, void *); -extern SEXP R_igraph_hrg_consensus(void *, void *, void *, void *); -extern SEXP R_igraph_hrg_create(void *, void *); -extern SEXP R_igraph_hrg_fit(void *, void *, void *, void *); -extern SEXP R_igraph_hrg_game(void *); -extern SEXP R_igraph_hrg_predict(void *, void *, void *, void *, void *); -extern SEXP R_igraph_hrg_resize(void *, void *); -extern SEXP R_igraph_hrg_sample(void *); -extern SEXP R_igraph_hrg_sample_many(void *, void *); -extern SEXP R_igraph_hrg_size(void *); -extern SEXP R_igraph_hsbm_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_hsbm_list_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_hub_and_authority_scores(void *, void *, void *, void *); -extern SEXP R_igraph_hub_score(void *, void *, void *, void *); -extern SEXP R_igraph_i_levc_arp(void *, void *, void *); -extern SEXP R_igraph_identical_graphs(void *, void *, void *); -extern SEXP R_igraph_incident(void *, void *, void *); -extern SEXP R_igraph_incident_edges(void *, void *, void *); -extern SEXP R_igraph_independence_number(void *); -extern SEXP R_igraph_independent_vertex_sets(void *, void *, void *); -extern SEXP R_igraph_induced_subgraph(void *, void *, void *); -extern SEXP R_igraph_induced_subgraph_map(void *, void *, void *); -extern SEXP R_igraph_intersection(void *, void *); -extern SEXP R_igraph_is_acyclic(void *); -extern SEXP R_igraph_is_biconnected(void *); -extern SEXP R_igraph_is_bipartite(void *); -extern SEXP R_igraph_is_chordal(void *, void *, void *, void *, void *); -extern SEXP R_igraph_is_complete(void *); -extern SEXP R_igraph_is_connected(void *, void *); -extern SEXP R_igraph_is_dag(void *); -extern SEXP R_igraph_is_directed(void *); -extern SEXP R_igraph_is_eulerian(void *); -extern SEXP R_igraph_is_forest(void *, void *); -extern SEXP R_igraph_is_graphical(void *, void *, void *); -extern SEXP R_igraph_is_loop(void *, void *); -extern SEXP R_igraph_is_matching(void *, void *, void *); -extern SEXP R_igraph_is_maximal_matching(void *, void *, void *); -extern SEXP R_igraph_is_minimal_separator(void *, void *); -extern SEXP R_igraph_is_multiple(void *, void *); -extern SEXP R_igraph_is_mutual(void *, void *, void *); -extern SEXP R_igraph_is_perfect(void *); -extern SEXP R_igraph_is_separator(void *, void *); -extern SEXP R_igraph_is_simple(void *); -extern SEXP R_igraph_is_tree(void *, void *); -extern SEXP R_igraph_isoclass(void *); -extern SEXP R_igraph_isoclass_create(void *, void *, void *); -extern SEXP R_igraph_isoclass_subgraph(void *, void *); -extern SEXP R_igraph_isomorphic(void *, void *); -extern SEXP R_igraph_isomorphic_bliss(void *, void *, void *, void *, void *); -extern SEXP R_igraph_isomorphic_vf2(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_join(void *, void *); -extern SEXP R_igraph_joint_degree_distribution(void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_joint_degree_matrix(void *, void *, void *, void *); -extern SEXP R_igraph_joint_type_distribution(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_k_regular_game(void *, void *, void *, void *); -extern SEXP R_igraph_kary_tree(void *, void *, void *); -extern SEXP R_igraph_kautz(void *, void *); -extern SEXP R_igraph_laplacian(void *, void *, void *, void *); -extern SEXP R_igraph_laplacian_spectral_embedding(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_largest_cliques(void *); -extern SEXP R_igraph_largest_independent_vertex_sets(void *); -extern SEXP R_igraph_largest_weighted_cliques(void *, void *); -extern SEXP R_igraph_lastcit_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_lattice(void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_bipartite(void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_circle(void *, void *); -extern SEXP R_igraph_layout_davidson_harel(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_drl(void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_drl_3d(void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_fruchterman_reingold(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_fruchterman_reingold_3d(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_gem(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_graphopt(void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_grid(void *, void *); -extern SEXP R_igraph_layout_grid_3d(void *, void *, void *); -extern SEXP R_igraph_layout_kamada_kawai(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_kamada_kawai_3d(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_lgl(void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_mds(void *, void *, void *); -extern SEXP R_igraph_layout_merge_dla(void *, void *); -extern SEXP R_igraph_layout_random(void *); -extern SEXP R_igraph_layout_random_3d(void *); -extern SEXP R_igraph_layout_reingold_tilford(void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_sphere(void *); -extern SEXP R_igraph_layout_star(void *, void *, void *); -extern SEXP R_igraph_layout_sugiyama(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_umap(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_umap_3d(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_layout_umap_compute_weights(void *, void *, void *); -extern SEXP R_igraph_lcf_vector(void *, void *, void *); -extern SEXP R_igraph_linegraph(void *); -extern SEXP R_igraph_list_triangles(void *); -extern SEXP R_igraph_local_efficiency(void *, void *, void *, void *, void *); -extern SEXP R_igraph_local_scan_0(void *, void *, void *); -extern SEXP R_igraph_local_scan_0_them(void *, void *, void *, void *); -extern SEXP R_igraph_local_scan_1_ecount(void *, void *, void *); -extern SEXP R_igraph_local_scan_1_ecount_them(void *, void *, void *, void *); -extern SEXP R_igraph_local_scan_k_ecount(void *, void *, void *, void *); -extern SEXP R_igraph_local_scan_k_ecount_them(void *, void *, void *, void *, void *); -extern SEXP R_igraph_local_scan_neighborhood_ecount(void *, void *, void *); -extern SEXP R_igraph_local_scan_subset_ecount(void *, void *, void *); -extern SEXP R_igraph_make_weak_ref(void *, void *, void *); -extern SEXP R_igraph_maxflow(void *, void *, void *, void *); -extern SEXP R_igraph_maximal_cliques(void *, void *, void *, void *); -extern SEXP R_igraph_maximal_cliques_count(void *, void *, void *, void *); -extern SEXP R_igraph_maximal_cliques_file(void *, void *, void *, void *, void *); -extern SEXP R_igraph_maximal_cliques_hist(void *, void *, void *); -extern SEXP R_igraph_maximal_independent_vertex_sets(void *); -extern SEXP R_igraph_maximum_bipartite_matching(void *, void *, void *, void *); -extern SEXP R_igraph_maximum_cardinality_search(void *); -extern SEXP R_igraph_mincut(void *, void *); -extern SEXP R_igraph_mincut_value(void *, void *); -extern SEXP R_igraph_minimum_cycle_basis(void *, void *, void *, void *, void *); -extern SEXP R_igraph_minimum_size_separators(void *); -extern SEXP R_igraph_minimum_spanning_tree_prim(void *, void *); -extern SEXP R_igraph_minimum_spanning_tree_unweighted(void *); -extern SEXP R_igraph_modularity(void *, void *, void *, void *, void *); -extern SEXP R_igraph_modularity_matrix(void *, void *, void *, void *); -extern SEXP R_igraph_moran_process(void *, void *, void *, void *, void *); -extern SEXP R_igraph_motifs_randesu(void *, void *, void *); -extern SEXP R_igraph_motifs_randesu_estimate(void *, void *, void *, void *, void *); -extern SEXP R_igraph_motifs_randesu_no(void *, void *, void *); -extern SEXP R_igraph_mybracket2(void *, void *, void *); -extern SEXP R_igraph_mybracket2_copy(void *, void *, void *); -extern SEXP R_igraph_mybracket2_names(void *, void *, void *); -extern SEXP R_igraph_mybracket2_set(void *, void *, void *, void *); -extern SEXP R_igraph_mybracket3_set(void *, void *, void *, void *, void *); -extern SEXP R_igraph_neighborhood(void *, void *, void *, void *, void *); -extern SEXP R_igraph_neighborhood_graphs(void *, void *, void *, void *, void *); -extern SEXP R_igraph_neighborhood_size(void *, void *, void *, void *, void *); -extern SEXP R_igraph_neighbors(void *, void *, void *); -extern SEXP R_igraph_no_components(void *, void *); -extern SEXP R_igraph_path_length_hist(void *, void *); -extern SEXP R_igraph_permute_vertices(void *, void *); -extern SEXP R_igraph_personalized_pagerank(void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_personalized_pagerank_vs(void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_power_law_fit(void *, void *, void *); -extern SEXP R_igraph_preference_game(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_pseudo_diameter(void *, void *, void *, void *); -extern SEXP R_igraph_pseudo_diameter_dijkstra(void *, void *, void *, void *, void *); -extern SEXP R_igraph_radius_dijkstra(void *, void *, void *); -extern SEXP R_igraph_random_edge_walk(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_random_sample(void *, void *, void *); -extern SEXP R_igraph_random_spanning_tree(void *, void *); -extern SEXP R_igraph_random_walk(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_read_graph_dimacs(void *, void *); -extern SEXP R_igraph_read_graph_dl(void *, void *); -extern SEXP R_igraph_read_graph_edgelist(void *, void *, void *); -extern SEXP R_igraph_read_graph_gml(void *); -extern SEXP R_igraph_read_graph_graphdb(void *, void *); -extern SEXP R_igraph_read_graph_graphml(void *, void *); -extern SEXP R_igraph_read_graph_lgl(void *, void *, void *, void *); -extern SEXP R_igraph_read_graph_ncol(void *, void *, void *, void *, void *); -extern SEXP R_igraph_read_graph_pajek(void *); -extern SEXP R_igraph_realize_bipartite_degree_sequence(void *, void *, void *, void *); -extern SEXP R_igraph_realize_degree_sequence(void *, void *, void *, void *); -extern SEXP R_igraph_recent_degree_aging_game(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_reciprocity(void *, void *, void *); -extern SEXP R_igraph_regular_tree(void *, void *, void *); -extern SEXP R_igraph_residual_graph(void *, void *, void *); -extern SEXP R_igraph_reverse_edges(void *, void *); -extern SEXP R_igraph_reverse_residual_graph(void *, void *, void *); -extern SEXP R_igraph_rewire(void *, void *, void *); -extern SEXP R_igraph_rewire_directed_edges(void *, void *, void *, void *); -extern SEXP R_igraph_rewire_edges(void *, void *, void *, void *); -extern SEXP R_igraph_ring(void *, void *, void *, void *); -extern SEXP R_igraph_roots_for_tree_layout(void *, void *, void *); -extern SEXP R_igraph_roulette_wheel_imitation(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_running_mean(void *, void *); -extern SEXP R_igraph_sample_dirichlet(void *, void *); -extern SEXP R_igraph_sample_sphere_surface(void *, void *, void *, void *); -extern SEXP R_igraph_sample_sphere_volume(void *, void *, void *, void *); -extern SEXP R_igraph_sbm_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_set_verbose(void *); -extern SEXP R_igraph_shortest_paths(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_similarity_dice(void *, void *, void *, void *); -extern SEXP R_igraph_similarity_dice_es(void *, void *, void *, void *); -extern SEXP R_igraph_similarity_dice_pairs(void *, void *, void *, void *); -extern SEXP R_igraph_similarity_inverse_log_weighted(void *, void *, void *); -extern SEXP R_igraph_similarity_jaccard(void *, void *, void *, void *); -extern SEXP R_igraph_similarity_jaccard_es(void *, void *, void *, void *); -extern SEXP R_igraph_similarity_jaccard_pairs(void *, void *, void *, void *); -extern SEXP R_igraph_simple_interconnected_islands_game(void *, void *, void *, void *); -extern SEXP R_igraph_simplify(void *, void *, void *, void *); -extern SEXP R_igraph_simplify_and_colorize(void *); -extern SEXP R_igraph_sir(void *, void *, void *, void *); -extern SEXP R_igraph_solve_lsap(void *, void *); -extern SEXP R_igraph_spanner(void *, void *, void *); -extern SEXP R_igraph_spinglass_community(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_spinglass_my_community(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_split_join_distance(void *, void *); -extern SEXP R_igraph_square_lattice(void *, void *, void *, void *, void *); -extern SEXP R_igraph_st_edge_connectivity(void *, void *, void *); -extern SEXP R_igraph_st_mincut(void *, void *, void *, void *); -extern SEXP R_igraph_st_mincut_value(void *, void *, void *, void *); -extern SEXP R_igraph_st_vertex_connectivity(void *, void *, void *); -extern SEXP R_igraph_star(void *, void *, void *); -extern SEXP R_igraph_static_fitness_game(void *, void *, void *, void *, void *); -extern SEXP R_igraph_static_power_law_game(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_stochastic_imitation(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_strength(void *, void *, void *, void *, void *); -extern SEXP R_igraph_subcomponent(void *, void *, void *); -extern SEXP R_igraph_subgraph_from_edges(void *, void *, void *); -extern SEXP R_igraph_subisomorphic(void *, void *); -extern SEXP R_igraph_subisomorphic_lad(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_subisomorphic_vf2(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_symmetric_tree(void *, void *); -extern SEXP R_igraph_to_directed(void *, void *); -extern SEXP R_igraph_to_prufer(void *); -extern SEXP R_igraph_to_undirected(void *, void *, void *); -extern SEXP R_igraph_topological_sorting(void *, void *); -extern SEXP R_igraph_transitive_closure_dag(void *); -extern SEXP R_igraph_transitivity_avglocal_undirected(void *, void *); -extern SEXP R_igraph_transitivity_barrat(void *, void *, void *, void *); -extern SEXP R_igraph_transitivity_local_undirected(void *, void *, void *); -extern SEXP R_igraph_transitivity_local_undirected_all(void *, void *); -extern SEXP R_igraph_transitivity_undirected(void *, void *); -extern SEXP R_igraph_tree_from_parent_vector(void *, void *); -extern SEXP R_igraph_tree_game(void *, void *, void *); -extern SEXP R_igraph_triad_census(void *); -extern SEXP R_igraph_triangular_lattice(void *, void *, void *); -extern SEXP R_igraph_trussness(void *); -extern SEXP R_igraph_turan(void *, void *); -extern SEXP R_igraph_unfold_tree(void *, void *, void *); -extern SEXP R_igraph_union(void *, void *); -extern SEXP R_igraph_vcount(void *); -extern SEXP R_igraph_vertex_coloring_greedy(void *, void *); -extern SEXP R_igraph_vertex_connectivity(void *, void *); -extern SEXP R_igraph_vertex_disjoint_paths(void *, void *, void *); -extern SEXP R_igraph_vertex_path_from_edge_path(void *, void *, void *, void *); -extern SEXP R_igraph_voronoi(void *, void *, void *, void *, void *); -extern SEXP R_igraph_vs_adj(void *, void *, void *, void *); -extern SEXP R_igraph_vs_nei(void *, void *, void *, void *); -extern SEXP R_igraph_walktrap_community(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_watts_strogatz_game(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_weak_ref_key(void *); -extern SEXP R_igraph_weak_ref_run_finalizer(void *); -extern SEXP R_igraph_weak_ref_value(void *); -extern SEXP R_igraph_weighted_adjacency(void *, void *, void *); -extern SEXP R_igraph_weighted_clique_number(void *, void *); -extern SEXP R_igraph_weighted_cliques(void *, void *, void *, void *, void *); -extern SEXP R_igraph_wheel(void *, void *, void *); -extern SEXP R_igraph_widest_path_widths_dijkstra(void *, void *, void *, void *, void *); -extern SEXP R_igraph_widest_path_widths_floyd_warshall(void *, void *, void *, void *, void *); -extern SEXP R_igraph_write_graph_dimacs(void *, void *, void *, void *, void *); -extern SEXP R_igraph_write_graph_dot(void *, void *); -extern SEXP R_igraph_write_graph_edgelist(void *, void *); -extern SEXP R_igraph_write_graph_gml(void *, void *, void *, void *); -extern SEXP R_igraph_write_graph_graphml(void *, void *, void *); -extern SEXP R_igraph_write_graph_leda(void *, void *, void *, void *); -extern SEXP R_igraph_write_graph_lgl(void *, void *, void *, void *, void *); -extern SEXP R_igraph_write_graph_ncol(void *, void *, void *, void *); -extern SEXP R_igraph_write_graph_pajek(void *, void *); -extern SEXP UUID_gen(void *); -extern SEXP make_lazy(void *, void *, void *); -extern SEXP make_lazy_dots(void *, void *); -extern SEXP promise_env_(void *); -extern SEXP promise_expr_(void *); +extern SEXP R_igraph_forest_fire_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_from_hrg_dendrogram(SEXP); +extern SEXP R_igraph_from_prufer(SEXP); +extern SEXP R_igraph_full(SEXP, SEXP, SEXP); +extern SEXP R_igraph_full_bipartite(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_full_citation(SEXP, SEXP); +extern SEXP R_igraph_full_multipartite(SEXP, SEXP, SEXP); +extern SEXP R_igraph_fundamental_cycles(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_generalized_petersen(SEXP, SEXP); +extern SEXP R_igraph_get_adjacency(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_adjedgelist(SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_adjlist(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_all_eids_between(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_all_shortest_paths(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_all_shortest_paths_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_all_simple_paths(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_all_simple_paths_pp(SEXP); +extern SEXP R_igraph_get_attr_mode(SEXP, SEXP); +extern SEXP R_igraph_get_biadjacency(SEXP, SEXP); +extern SEXP R_igraph_get_diameter(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_edge(SEXP, SEXP); +extern SEXP R_igraph_get_edgelist(SEXP, SEXP); +extern SEXP R_igraph_get_eids(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_graph_id(SEXP); +extern SEXP R_igraph_get_isomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_k_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_laplacian(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_laplacian_sparse(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_shortest_path(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_shortest_path_bellman_ford(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_shortest_path_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_stochastic(SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_stochastic_sparse(SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_subisomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_widest_path(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_widest_paths(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_girth(SEXP, SEXP); +extern SEXP R_igraph_global_efficiency(SEXP, SEXP, SEXP); +extern SEXP R_igraph_gomory_hu_tree(SEXP, SEXP); +extern SEXP R_igraph_graph_center_dijkstra(SEXP, SEXP, SEXP); +extern SEXP R_igraph_graph_count(SEXP, SEXP); +extern SEXP R_igraph_graph_power(SEXP, SEXP, SEXP); +extern SEXP R_igraph_graph_version(SEXP); +extern SEXP R_igraph_graphlets(SEXP, SEXP, SEXP); +extern SEXP R_igraph_graphlets_candidate_basis(SEXP, SEXP); +extern SEXP R_igraph_graphlets_project(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_grg_game(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_growing_random_game(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_harmonic_centrality_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_has_loop(SEXP); +extern SEXP R_igraph_has_multiple(SEXP); +extern SEXP R_igraph_has_mutual(SEXP, SEXP); +extern SEXP R_igraph_hrg_consensus(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_hrg_create(SEXP, SEXP); +extern SEXP R_igraph_hrg_fit(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_hrg_game(SEXP); +extern SEXP R_igraph_hrg_predict(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_hrg_resize(SEXP, SEXP); +extern SEXP R_igraph_hrg_sample(SEXP); +extern SEXP R_igraph_hrg_sample_many(SEXP, SEXP); +extern SEXP R_igraph_hrg_size(SEXP); +extern SEXP R_igraph_hsbm_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_hsbm_list_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_hub_and_authority_scores(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_hub_score(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_i_levc_arp(SEXP, SEXP, SEXP); +extern SEXP R_igraph_identical_graphs(SEXP, SEXP, SEXP); +extern SEXP R_igraph_incident(SEXP, SEXP, SEXP); +extern SEXP R_igraph_incident_edges(SEXP, SEXP, SEXP); +extern SEXP R_igraph_independence_number(SEXP); +extern SEXP R_igraph_independent_vertex_sets(SEXP, SEXP, SEXP); +extern SEXP R_igraph_induced_subgraph(SEXP, SEXP, SEXP); +extern SEXP R_igraph_induced_subgraph_map(SEXP, SEXP, SEXP); +extern SEXP R_igraph_intersection(SEXP, SEXP); +extern SEXP R_igraph_is_acyclic(SEXP); +extern SEXP R_igraph_is_biconnected(SEXP); +extern SEXP R_igraph_is_bipartite(SEXP); +extern SEXP R_igraph_is_chordal(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_is_complete(SEXP); +extern SEXP R_igraph_is_connected(SEXP, SEXP); +extern SEXP R_igraph_is_dag(SEXP); +extern SEXP R_igraph_is_directed(SEXP); +extern SEXP R_igraph_is_eulerian(SEXP); +extern SEXP R_igraph_is_forest(SEXP, SEXP); +extern SEXP R_igraph_is_graphical(SEXP, SEXP, SEXP); +extern SEXP R_igraph_is_loop(SEXP, SEXP); +extern SEXP R_igraph_is_matching(SEXP, SEXP, SEXP); +extern SEXP R_igraph_is_maximal_matching(SEXP, SEXP, SEXP); +extern SEXP R_igraph_is_minimal_separator(SEXP, SEXP); +extern SEXP R_igraph_is_multiple(SEXP, SEXP); +extern SEXP R_igraph_is_mutual(SEXP, SEXP, SEXP); +extern SEXP R_igraph_is_perfect(SEXP); +extern SEXP R_igraph_is_separator(SEXP, SEXP); +extern SEXP R_igraph_is_simple(SEXP); +extern SEXP R_igraph_is_tree(SEXP, SEXP); +extern SEXP R_igraph_isoclass(SEXP); +extern SEXP R_igraph_isoclass_create(SEXP, SEXP, SEXP); +extern SEXP R_igraph_isoclass_subgraph(SEXP, SEXP); +extern SEXP R_igraph_isomorphic(SEXP, SEXP); +extern SEXP R_igraph_isomorphic_bliss(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_isomorphic_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_join(SEXP, SEXP); +extern SEXP R_igraph_joint_degree_distribution(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_joint_degree_matrix(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_joint_type_distribution(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_k_regular_game(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_kary_tree(SEXP, SEXP, SEXP); +extern SEXP R_igraph_kautz(SEXP, SEXP); +extern SEXP R_igraph_laplacian(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_laplacian_spectral_embedding(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_largest_cliques(SEXP); +extern SEXP R_igraph_largest_independent_vertex_sets(SEXP); +extern SEXP R_igraph_largest_weighted_cliques(SEXP, SEXP); +extern SEXP R_igraph_lastcit_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_lattice(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_bipartite(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_circle(SEXP, SEXP); +extern SEXP R_igraph_layout_davidson_harel(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_drl(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_drl_3d(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_fruchterman_reingold(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_fruchterman_reingold_3d(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_gem(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_graphopt(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_grid(SEXP, SEXP); +extern SEXP R_igraph_layout_grid_3d(SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_kamada_kawai(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_kamada_kawai_3d(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_lgl(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_mds(SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_merge_dla(SEXP, SEXP); +extern SEXP R_igraph_layout_random(SEXP); +extern SEXP R_igraph_layout_random_3d(SEXP); +extern SEXP R_igraph_layout_reingold_tilford(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_sphere(SEXP); +extern SEXP R_igraph_layout_star(SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_sugiyama(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_umap(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_umap_3d(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_umap_compute_weights(SEXP, SEXP, SEXP); +extern SEXP R_igraph_lcf_vector(SEXP, SEXP, SEXP); +extern SEXP R_igraph_linegraph(SEXP); +extern SEXP R_igraph_list_triangles(SEXP); +extern SEXP R_igraph_local_efficiency(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_0(SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_0_them(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_1_ecount(SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_1_ecount_them(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_k_ecount(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_k_ecount_them(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_neighborhood_ecount(SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_subset_ecount(SEXP, SEXP, SEXP); +extern SEXP R_igraph_make_weak_ref(SEXP, SEXP, SEXP); +extern SEXP R_igraph_maxflow(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximal_cliques(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximal_cliques_count(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximal_cliques_file(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximal_cliques_hist(SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximal_independent_vertex_sets(SEXP); +extern SEXP R_igraph_maximum_bipartite_matching(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximum_cardinality_search(SEXP); +extern SEXP R_igraph_mincut(SEXP, SEXP); +extern SEXP R_igraph_mincut_value(SEXP, SEXP); +extern SEXP R_igraph_minimum_cycle_basis(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_minimum_size_separators(SEXP); +extern SEXP R_igraph_minimum_spanning_tree_prim(SEXP, SEXP); +extern SEXP R_igraph_minimum_spanning_tree_unweighted(SEXP); +extern SEXP R_igraph_modularity(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_modularity_matrix(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_moran_process(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_motifs_randesu(SEXP, SEXP, SEXP); +extern SEXP R_igraph_motifs_randesu_estimate(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_motifs_randesu_no(SEXP, SEXP, SEXP); +extern SEXP R_igraph_mybracket2(SEXP, SEXP, SEXP); +extern SEXP R_igraph_mybracket2_copy(SEXP, SEXP, SEXP); +extern SEXP R_igraph_mybracket2_names(SEXP, SEXP, SEXP); +extern SEXP R_igraph_mybracket2_set(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_mybracket3_set(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_neighborhood(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_neighborhood_graphs(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_neighborhood_size(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_neighbors(SEXP, SEXP, SEXP); +extern SEXP R_igraph_no_components(SEXP, SEXP); +extern SEXP R_igraph_path_length_hist(SEXP, SEXP); +extern SEXP R_igraph_permute_vertices(SEXP, SEXP); +extern SEXP R_igraph_personalized_pagerank(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_personalized_pagerank_vs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_power_law_fit(SEXP, SEXP, SEXP); +extern SEXP R_igraph_preference_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_pseudo_diameter(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_pseudo_diameter_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_radius_dijkstra(SEXP, SEXP, SEXP); +extern SEXP R_igraph_random_edge_walk(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_random_sample(SEXP, SEXP, SEXP); +extern SEXP R_igraph_random_spanning_tree(SEXP, SEXP); +extern SEXP R_igraph_random_walk(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_read_graph_dimacs(SEXP, SEXP); +extern SEXP R_igraph_read_graph_dl(SEXP, SEXP); +extern SEXP R_igraph_read_graph_edgelist(SEXP, SEXP, SEXP); +extern SEXP R_igraph_read_graph_gml(SEXP); +extern SEXP R_igraph_read_graph_graphdb(SEXP, SEXP); +extern SEXP R_igraph_read_graph_graphml(SEXP, SEXP); +extern SEXP R_igraph_read_graph_lgl(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_read_graph_ncol(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_read_graph_pajek(SEXP); +extern SEXP R_igraph_realize_bipartite_degree_sequence(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_realize_degree_sequence(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_recent_degree_aging_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_reciprocity(SEXP, SEXP, SEXP); +extern SEXP R_igraph_regular_tree(SEXP, SEXP, SEXP); +extern SEXP R_igraph_residual_graph(SEXP, SEXP, SEXP); +extern SEXP R_igraph_reverse_edges(SEXP, SEXP); +extern SEXP R_igraph_reverse_residual_graph(SEXP, SEXP, SEXP); +extern SEXP R_igraph_rewire(SEXP, SEXP, SEXP); +extern SEXP R_igraph_rewire_directed_edges(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_rewire_edges(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_ring(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_roots_for_tree_layout(SEXP, SEXP, SEXP); +extern SEXP R_igraph_roulette_wheel_imitation(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_running_mean(SEXP, SEXP); +extern SEXP R_igraph_sample_dirichlet(SEXP, SEXP); +extern SEXP R_igraph_sample_sphere_surface(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_sample_sphere_volume(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_sbm_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_set_verbose(SEXP); +extern SEXP R_igraph_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_dice(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_dice_es(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_dice_pairs(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_inverse_log_weighted(SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_jaccard(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_jaccard_es(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_jaccard_pairs(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_simple_interconnected_islands_game(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_simplify(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_simplify_and_colorize(SEXP); +extern SEXP R_igraph_sir(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_solve_lsap(SEXP, SEXP); +extern SEXP R_igraph_spanner(SEXP, SEXP, SEXP); +extern SEXP R_igraph_spinglass_community(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_spinglass_my_community(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_split_join_distance(SEXP, SEXP); +extern SEXP R_igraph_square_lattice(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_st_edge_connectivity(SEXP, SEXP, SEXP); +extern SEXP R_igraph_st_mincut(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_st_mincut_value(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_st_vertex_connectivity(SEXP, SEXP, SEXP); +extern SEXP R_igraph_star(SEXP, SEXP, SEXP); +extern SEXP R_igraph_static_fitness_game(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_static_power_law_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_stochastic_imitation(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_strength(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_subcomponent(SEXP, SEXP, SEXP); +extern SEXP R_igraph_subgraph_from_edges(SEXP, SEXP, SEXP); +extern SEXP R_igraph_subisomorphic(SEXP, SEXP); +extern SEXP R_igraph_subisomorphic_lad(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_subisomorphic_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_symmetric_tree(SEXP, SEXP); +extern SEXP R_igraph_to_directed(SEXP, SEXP); +extern SEXP R_igraph_to_prufer(SEXP); +extern SEXP R_igraph_to_undirected(SEXP, SEXP, SEXP); +extern SEXP R_igraph_topological_sorting(SEXP, SEXP); +extern SEXP R_igraph_transitive_closure_dag(SEXP); +extern SEXP R_igraph_transitivity_avglocal_undirected(SEXP, SEXP); +extern SEXP R_igraph_transitivity_barrat(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_transitivity_local_undirected(SEXP, SEXP, SEXP); +extern SEXP R_igraph_transitivity_local_undirected_all(SEXP, SEXP); +extern SEXP R_igraph_transitivity_undirected(SEXP, SEXP); +extern SEXP R_igraph_tree_from_parent_vector(SEXP, SEXP); +extern SEXP R_igraph_tree_game(SEXP, SEXP, SEXP); +extern SEXP R_igraph_triad_census(SEXP); +extern SEXP R_igraph_triangular_lattice(SEXP, SEXP, SEXP); +extern SEXP R_igraph_trussness(SEXP); +extern SEXP R_igraph_turan(SEXP, SEXP); +extern SEXP R_igraph_unfold_tree(SEXP, SEXP, SEXP); +extern SEXP R_igraph_union(SEXP, SEXP); +extern SEXP R_igraph_vcount(SEXP); +extern SEXP R_igraph_vertex_coloring_greedy(SEXP, SEXP); +extern SEXP R_igraph_vertex_connectivity(SEXP, SEXP); +extern SEXP R_igraph_vertex_disjoint_paths(SEXP, SEXP, SEXP); +extern SEXP R_igraph_vertex_path_from_edge_path(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_voronoi(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_vs_adj(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_vs_nei(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_walktrap_community(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_watts_strogatz_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_weak_ref_key(SEXP); +extern SEXP R_igraph_weak_ref_run_finalizer(SEXP); +extern SEXP R_igraph_weak_ref_value(SEXP); +extern SEXP R_igraph_weighted_adjacency(SEXP, SEXP, SEXP); +extern SEXP R_igraph_weighted_clique_number(SEXP, SEXP); +extern SEXP R_igraph_weighted_cliques(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_wheel(SEXP, SEXP, SEXP); +extern SEXP R_igraph_widest_path_widths_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_widest_path_widths_floyd_warshall(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_dimacs(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_dot(SEXP, SEXP); +extern SEXP R_igraph_write_graph_edgelist(SEXP, SEXP); +extern SEXP R_igraph_write_graph_gml(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_graphml(SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_leda(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_lgl(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_ncol(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_pajek(SEXP, SEXP); +extern SEXP UUID_gen(SEXP); +extern SEXP make_lazy(SEXP, SEXP, SEXP); +extern SEXP make_lazy_dots(SEXP, SEXP); +extern SEXP promise_env_(SEXP); +extern SEXP promise_expr_(SEXP); static const R_CallMethodDef CallEntries[] = { {"R_igraph_add_edges", (DL_FUNC) &R_igraph_add_edges, 2}, From 6443841e8640ad2095f8bf6b0c07dd86f8bc284c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 10 Apr 2025 11:10:22 +0200 Subject: [PATCH 5/8] Undo air formatting --- R/attributes.R | 204 ++++++++++--------------------------------------- 1 file changed, 41 insertions(+), 163 deletions(-) diff --git a/R/attributes.R b/R/attributes.R index 44425362dfb..7821b9f6fe3 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -8,13 +8,8 @@ #' @inheritParams set_vertex_attr #' @keywords internal #' @export -set.vertex.attribute <- function(graph, name, index = V(graph), value) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "set.vertex.attribute()", - "set_vertex_attr()" - ) +set.vertex.attribute <- function(graph, name, index = V(graph), value) { # nocov start + lifecycle::deprecate_soft("2.0.0", "set.vertex.attribute()", "set_vertex_attr()") set_vertex_attr(graph = graph, name = name, index = index, value = value) } # nocov end @@ -28,13 +23,8 @@ set.vertex.attribute <- function(graph, name, index = V(graph), value) { #' @inheritParams set_graph_attr #' @keywords internal #' @export -set.graph.attribute <- function(graph, name, value) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "set.graph.attribute()", - "set_graph_attr()" - ) +set.graph.attribute <- function(graph, name, value) { # nocov start + lifecycle::deprecate_soft("2.0.0", "set.graph.attribute()", "set_graph_attr()") set_graph_attr(graph = graph, name = name, value = value) } # nocov end @@ -48,8 +38,7 @@ set.graph.attribute <- function(graph, name, value) { #' @inheritParams set_edge_attr #' @keywords internal #' @export -set.edge.attribute <- function(graph, name, index = E(graph), value) { - # nocov start +set.edge.attribute <- function(graph, name, index = E(graph), value) { # nocov start lifecycle::deprecate_soft("2.0.0", "set.edge.attribute()", "set_edge_attr()") set_edge_attr(graph = graph, name = name, index = index, value = value) } # nocov end @@ -64,13 +53,8 @@ set.edge.attribute <- function(graph, name, index = E(graph), value) { #' @inheritParams delete_vertex_attr #' @keywords internal #' @export -remove.vertex.attribute <- function(graph, name) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "remove.vertex.attribute()", - "delete_vertex_attr()" - ) +remove.vertex.attribute <- function(graph, name) { # nocov start + lifecycle::deprecate_soft("2.0.0", "remove.vertex.attribute()", "delete_vertex_attr()") delete_vertex_attr(graph = graph, name = name) } # nocov end @@ -84,13 +68,8 @@ remove.vertex.attribute <- function(graph, name) { #' @inheritParams delete_graph_attr #' @keywords internal #' @export -remove.graph.attribute <- function(graph, name) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "remove.graph.attribute()", - "delete_graph_attr()" - ) +remove.graph.attribute <- function(graph, name) { # nocov start + lifecycle::deprecate_soft("2.0.0", "remove.graph.attribute()", "delete_graph_attr()") delete_graph_attr(graph = graph, name = name) } # nocov end @@ -104,13 +83,8 @@ remove.graph.attribute <- function(graph, name) { #' @inheritParams delete_edge_attr #' @keywords internal #' @export -remove.edge.attribute <- function(graph, name) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "remove.edge.attribute()", - "delete_edge_attr()" - ) +remove.edge.attribute <- function(graph, name) { # nocov start + lifecycle::deprecate_soft("2.0.0", "remove.edge.attribute()", "delete_edge_attr()") delete_edge_attr(graph = graph, name = name) } # nocov end @@ -124,13 +98,8 @@ remove.edge.attribute <- function(graph, name) { #' @inheritParams vertex_attr_names #' @keywords internal #' @export -list.vertex.attributes <- function(graph) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "list.vertex.attributes()", - "vertex_attr_names()" - ) +list.vertex.attributes <- function(graph) { # nocov start + lifecycle::deprecate_soft("2.0.0", "list.vertex.attributes()", "vertex_attr_names()") vertex_attr_names(graph = graph) } # nocov end @@ -144,13 +113,8 @@ list.vertex.attributes <- function(graph) { #' @inheritParams graph_attr_names #' @keywords internal #' @export -list.graph.attributes <- function(graph) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "list.graph.attributes()", - "graph_attr_names()" - ) +list.graph.attributes <- function(graph) { # nocov start + lifecycle::deprecate_soft("2.0.0", "list.graph.attributes()", "graph_attr_names()") graph_attr_names(graph = graph) } # nocov end @@ -164,13 +128,8 @@ list.graph.attributes <- function(graph) { #' @inheritParams edge_attr_names #' @keywords internal #' @export -list.edge.attributes <- function(graph) { - # nocov start - lifecycle::deprecate_soft( - "2.0.0", - "list.edge.attributes()", - "edge_attr_names()" - ) +list.edge.attributes <- function(graph) { # nocov start + lifecycle::deprecate_soft("2.0.0", "list.edge.attributes()", "edge_attr_names()") edge_attr_names(graph = graph) } # nocov end @@ -184,8 +143,7 @@ list.edge.attributes <- function(graph) { #' @inheritParams is_weighted #' @keywords internal #' @export -is.weighted <- function(graph) { - # nocov start +is.weighted <- function(graph) { # nocov start lifecycle::deprecate_soft("2.0.0", "is.weighted()", "is_weighted()") is_weighted(graph = graph) } # nocov end @@ -200,8 +158,7 @@ is.weighted <- function(graph) { #' @inheritParams is_named #' @keywords internal #' @export -is.named <- function(graph) { - # nocov start +is.named <- function(graph) { # nocov start lifecycle::deprecate_soft("2.0.0", "is.named()", "is_named()") is_named(graph = graph) } # nocov end @@ -216,8 +173,7 @@ is.named <- function(graph) { #' @inheritParams is_bipartite #' @keywords internal #' @export -is.bipartite <- function(graph) { - # nocov start +is.bipartite <- function(graph) { # nocov start lifecycle::deprecate_soft("2.0.0", "is.bipartite()", "is_bipartite()") is_bipartite(graph = graph) } # nocov end @@ -232,8 +188,7 @@ is.bipartite <- function(graph) { #' @inheritParams vertex_attr #' @keywords internal #' @export -get.vertex.attribute <- function(graph, name, index = V(graph)) { - # nocov start +get.vertex.attribute <- function(graph, name, index = V(graph)) { # nocov start lifecycle::deprecate_soft("2.0.0", "get.vertex.attribute()", "vertex_attr()") vertex_attr(graph = graph, name = name, index = index) } # nocov end @@ -248,8 +203,7 @@ get.vertex.attribute <- function(graph, name, index = V(graph)) { #' @inheritParams graph_attr #' @keywords internal #' @export -get.graph.attribute <- function(graph, name) { - # nocov start +get.graph.attribute <- function(graph, name) { # nocov start lifecycle::deprecate_soft("2.0.0", "get.graph.attribute()", "graph_attr()") graph_attr(graph = graph, name = name) } # nocov end @@ -264,8 +218,7 @@ get.graph.attribute <- function(graph, name) { #' @inheritParams edge_attr #' @keywords internal #' @export -get.edge.attribute <- function(graph, name, index = E(graph)) { - # nocov start +get.edge.attribute <- function(graph, name, index = E(graph)) { # nocov start lifecycle::deprecate_soft("2.0.0", "get.edge.attribute()", "edge_attr()") edge_attr(graph = graph, name = name, index = index) } # nocov end @@ -388,25 +341,13 @@ set_graph_attr <- function(graph, name, value) { ensure_igraph(graph) - .Call( - R_igraph_mybracket3_set, - graph, - igraph_t_idx_attr, - igraph_attr_idx_graph, - name, - value - ) + .Call(R_igraph_mybracket3_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, name, value) } #' @export graph.attributes <- function(graph) { ensure_igraph(graph) - .Call( - R_igraph_mybracket2_copy, - graph, - igraph_t_idx_attr, - igraph_attr_idx_graph - ) + .Call(R_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_graph) } #' @export @@ -417,13 +358,7 @@ graph.attributes <- function(graph) { value <- as.list(value) } - .Call( - R_igraph_mybracket2_set, - graph, - igraph_t_idx_attr, - igraph_attr_idx_graph, - value - ) + .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, value) } @@ -593,13 +528,7 @@ i_set_vertex_attr <- function( } } - .Call( - R_igraph_mybracket2_set, - graph, - igraph_t_idx_attr, - igraph_attr_idx_vertex, - vattrs - ) + .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, vattrs) } #' @export @@ -610,12 +539,7 @@ vertex.attributes <- function(graph, index = V(graph)) { index <- as_igraph_vs(graph, index) } - res <- .Call( - R_igraph_mybracket2_copy, - graph, - igraph_t_idx_attr, - igraph_attr_idx_vertex - ) + res <- .Call(R_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_vertex) if (!missing(index)) { index_is_natural_sequence <- (length(index) == vcount(graph) && @@ -663,13 +587,7 @@ set_value_at <- function(value, idx, length_out) { value <- map(value, set_value_at, idx = index, length_out = length(V(graph))) } - .Call( - R_igraph_mybracket2_set, - graph, - igraph_t_idx_attr, - igraph_attr_idx_vertex, - value - ) + .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, value) } @@ -839,13 +757,7 @@ i_set_edge_attr <- function( } } - .Call( - R_igraph_mybracket2_set, - graph, - igraph_t_idx_attr, - igraph_attr_idx_edge, - eattrs - ) + .Call(R_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_edge, eattrs) } #' @export @@ -856,17 +768,10 @@ edge.attributes <- function(graph, index = E(graph)) { index <- as_igraph_es(graph, index) } - res <- .Call( - R_igraph_mybracket2_copy, - graph, - igraph_t_idx_attr, - igraph_attr_idx_edge - ) + res <- .Call(R_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_edge) - if ( - !missing(index) && - (length(index) != ecount(graph) || any(index != E(graph))) - ) { + if (!missing(index) && + (length(index) != ecount(graph) || any(index != E(graph)))) { for (i in seq_along(res)) { res[[i]] <- res[[i]][index] } @@ -894,10 +799,8 @@ edge.attributes <- function(graph, index = E(graph)) { } } - if ( - !missing(index) && - (length(index) != ecount(graph) || any(index != E(graph))) - ) { + if (!missing(index) && + (length(index) != ecount(graph) || any(index != E(graph)))) { es <- E(graph) for (i in seq_along(value)) { tmp <- value[[i]] @@ -931,12 +834,7 @@ edge.attributes <- function(graph, index = E(graph)) { #' graph_attr_names(g) graph_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( - R_igraph_mybracket2_names, - graph, - igraph_t_idx_attr, - igraph_attr_idx_graph - ) + res <- .Call(R_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_graph) if (is.null(res)) { res <- character() } @@ -960,12 +858,7 @@ graph_attr_names <- function(graph) { vertex_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( - R_igraph_mybracket2_names, - graph, - igraph_t_idx_attr, - igraph_attr_idx_vertex - ) + res <- .Call(R_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_vertex) if (is.null(res)) { res <- character() @@ -988,12 +881,7 @@ vertex_attr_names <- function(graph) { #' plot(g) edge_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( - R_igraph_mybracket2_names, - graph, - igraph_t_idx_attr, - igraph_attr_idx_edge - ) + res <- .Call(R_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_edge) if (is.null(res)) { res <- character() } @@ -1228,20 +1116,10 @@ igraph.i.attribute.combination <- function(comb) { } else { known <- data.frame( n = c( - "ignore", - "sum", - "prod", - "min", - "max", - "random", - "first", - "last", - "mean", - "median", - "concat" + "ignore", "sum", "prod", "min", "max", "random", + "first", "last", "mean", "median", "concat" ), - i = c(0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - stringsAsFactors = FALSE + i = c(0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), stringsAsFactors = FALSE ) x <- pmatch(tolower(x), known[, 1]) if (is.na(x)) { From 938618d4321f537ce5ecca42aa806412e1e713f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 10 Apr 2025 11:17:17 +0200 Subject: [PATCH 6/8] Undo --- src/cpp11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 336915da85d..5e7d835f982 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -949,4 +949,4 @@ extern "C" attribute_visible void R_init_igraph(DllInfo* dll){ R_useDynamicSymbols(dll, FALSE); igraph_init(dll); R_forceSymbols(dll, TRUE); -} \ No newline at end of file +} From bcde90883be56b3f1f90080bdc7ab36e32f9963b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 10 Apr 2025 11:17:59 +0200 Subject: [PATCH 7/8] Blanket rlang import --- NAMESPACE | 12 ------------ R/igraph-package.R | 11 ----------- 2 files changed, 23 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index a02c0894a39..e77c9afcf79 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -933,18 +933,6 @@ importFrom(magrittr,"%>%") importFrom(pkgconfig,get_config) importFrom(pkgconfig,set_config) importFrom(pkgconfig,set_config_in) -importFrom(rlang,"%||%") -importFrom(rlang,.data) -importFrom(rlang,.env) -importFrom(rlang,as_function) -importFrom(rlang,check_dots_empty) -importFrom(rlang,check_installed) -importFrom(rlang,global_env) -importFrom(rlang,inject) -importFrom(rlang,is_logical) -importFrom(rlang,is_true) -importFrom(rlang,set_names) -importFrom(rlang,warn) importFrom(stats,IQR) importFrom(stats,as.dendrogram) importFrom(stats,as.hclust) diff --git a/R/igraph-package.R b/R/igraph-package.R index 70deda412ea..256aa95ebfe 100644 --- a/R/igraph-package.R +++ b/R/igraph-package.R @@ -3,17 +3,6 @@ ## usethis namespace: start #' @importFrom lifecycle deprecated #' @importFrom magrittr %>% -#' @importFrom rlang .data .env -#' @importFrom rlang check_dots_empty -#' @importFrom rlang check_installed -#' @importFrom rlang inject -#' @importFrom rlang warn -#' @importFrom rlang %||% -#' @importFrom rlang as_function -#' @importFrom rlang global_env -#' @importFrom rlang set_names -#' @importFrom rlang is_logical -#' @importFrom rlang is_true #' @import rlang ## usethis namespace: end NULL From 620eeff735377085c9e15d0750e5e4c24a5847ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 13 May 2025 13:24:46 +0200 Subject: [PATCH 8/8] fix pr --- R/attributes.R | 61 +++-- R/make.R | 394 +++++++++++++++++++--------- R/utils-assert-character.R | 7 - tests/testthat/_snaps/attributes.md | 8 + tests/testthat/test-attributes.R | 72 +++-- tools/weights.R | 22 ++ 6 files changed, 399 insertions(+), 165 deletions(-) delete mode 100644 R/utils-assert-character.R create mode 100644 tools/weights.R diff --git a/R/attributes.R b/R/attributes.R index c088499ab1c..20ef1c937bf 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -326,7 +326,7 @@ graph_attr <- function(graph, name) { return(graph.attributes(graph)) } - assert_character(name) + check_string(name) .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ name @@ -361,7 +361,7 @@ graph_attr <- function(graph, name) { if (missing(name)) { `graph.attributes<-`(graph, value) } else { - assert_character(name) + check_string(name) set_graph_attr(graph, name, value) } } @@ -384,7 +384,7 @@ graph_attr <- function(graph, name) { #' g #' plot(g) set_graph_attr <- function(graph, name, value) { - assert_character(name) + check_string(name) ensure_igraph(graph) @@ -457,7 +457,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { return(vertex.attributes(graph, index = index)) } - assert_character(name) + check_string(name) myattr <- .Call( R_igraph_mybracket2, @@ -501,7 +501,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { if (missing(name)) { `vertex.attributes<-`(graph, index = index, value = value) } else { - assert_character(name) + check_string(name) set_vertex_attr(graph, name = name, index = index, value = value) } } @@ -526,7 +526,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { #' g #' plot(g) set_vertex_attr <- function(graph, name, index = V(graph), value) { - assert_character(name) + check_string(name) if (is_complete_iterator(index)) { i_set_vertex_attr(graph = graph, name = name, value = value, check = FALSE) @@ -543,7 +543,7 @@ i_set_vertex_attr <- function( check = TRUE ) { ensure_igraph(graph) - assert_character(name) + check_string(name) if (is.null(value)) { return(graph) @@ -645,7 +645,9 @@ set_value_at <- function(value, idx, length_out) { } if (!all(lengths(value) == length(index))) { - cli::cli_abort("Invalid attribute value length, must match number of vertices.") + cli::cli_abort( + "Invalid attribute value length, must match number of vertices." + ) } if (!missing(index)) { @@ -657,7 +659,12 @@ set_value_at <- function(value, idx, length_out) { } if (!missing(index) && !index_is_natural_sequence(index, graph)) { - value <- map(value, set_value_at, idx = index, length_out = length(V(graph))) + value <- map( + value, + set_value_at, + idx = index, + length_out = length(V(graph)) + ) } .Call( @@ -700,7 +707,7 @@ edge_attr <- function(graph, name, index = E(graph)) { edge.attributes(graph, index = index) } } else { - assert_character(name) + check_string(name) myattr <- .Call( R_igraph_mybracket2, graph, @@ -745,7 +752,7 @@ edge_attr <- function(graph, name, index = E(graph)) { if (missing(name)) { `edge.attributes<-`(graph, index = index, value = value) } else { - assert_character(name) + check_string(name) set_edge_attr(graph, name = name, index = index, value = value) } } @@ -770,7 +777,7 @@ edge_attr <- function(graph, name, index = E(graph)) { #' g #' plot(g) set_edge_attr <- function(graph, name, index = E(graph), value) { - assert_character(name) + check_string(name) if (is_complete_iterator(index)) { i_set_edge_attr(graph = graph, name = name, value = value, check = FALSE) } else { @@ -786,7 +793,7 @@ i_set_edge_attr <- function( check = TRUE ) { ensure_igraph(graph) - assert_character(name) + check_string(name) if (is.null(value)) { return(graph) @@ -1013,7 +1020,7 @@ edge_attr_names <- function(graph) { #' graph_attr_names(g2) delete_graph_attr <- function(graph, name) { ensure_igraph(graph) - assert_character(name) + check_string(name) if (!name %in% graph_attr_names(graph)) { cli::cli_abort("No graph attribute {.arg {name}} found.") @@ -1053,7 +1060,7 @@ delete_graph_attr <- function(graph, name) { #' vertex_attr_names(g2) delete_vertex_attr <- function(graph, name) { ensure_igraph(graph) - assert_character(name) + check_string(name) if (!name %in% vertex_attr_names(graph)) { cli::cli_abort("No vertex attribute {.arg {name}} found.") @@ -1093,7 +1100,7 @@ delete_vertex_attr <- function(graph, name) { #' edge_attr_names(g2) delete_edge_attr <- function(graph, name) { ensure_igraph(graph) - assert_character(name) + check_string(name) if (!name %in% edge_attr_names(graph)) { cli::cli_abort("No edge attribute {.arg {name}} found.") @@ -1208,10 +1215,16 @@ igraph.i.attribute.combination <- function(comb) { comb <- list(comb) } comb <- as.list(comb) - if (any(!sapply(comb, function(x) { - is.function(x) || (is.character(x) && length(x) == 1) - }))) { - cli::cli_abort("Attribute combination element must be a function or character scalar.") + if ( + any( + !sapply(comb, function(x) { + is.function(x) || (is.character(x) && length(x) == 1) + }) + ) + ) { + cli::cli_abort( + "Attribute combination element must be a function or character scalar." + ) } if (is.null(names(comb))) { names(comb) <- rep("", length(comb)) @@ -1242,7 +1255,9 @@ igraph.i.attribute.combination <- function(comb) { ) x <- pmatch(tolower(x), known[, 1]) if (is.na(x)) { - cli::cli_abort("Unknown/unambigous attribute combination specification.") + cli::cli_abort( + "Unknown/unambigous attribute combination specification." + ) } known[, 2][x] } @@ -1373,7 +1388,7 @@ NULL #' g$name <- "10-ring" #' g$name `$.igraph` <- function(x, name) { - assert_character(name) + check_string(name) graph_attr(x, name) } @@ -1383,7 +1398,7 @@ NULL #' @name igraph-dollar #' @export `$<-.igraph` <- function(x, name, value) { - assert_character(name) + check_string(name) set_graph_attr(x, name, value) } diff --git a/R/make.R b/R/make.R index c54bf98d7bf..4e4d660e683 100644 --- a/R/make.R +++ b/R/make.R @@ -8,10 +8,20 @@ #' @inheritParams make_graph #' @keywords internal #' @export -graph <- function(edges, ..., n = max(edges), isolates = NULL, directed = TRUE, dir = directed, simplify = TRUE) { # nocov start +graph <- function( + edges, + ..., + n = max(edges), + isolates = NULL, + directed = TRUE, + dir = directed, + simplify = TRUE +) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph()", "make_graph()") if (inherits(edges, "formula")) { - if (!missing(n)) cli::cli_abort("{.arg n} should not be given for graph literals") + if (!missing(n)) + cli::cli_abort("{.arg n} should not be given for graph literals") if (!missing(isolates)) { cli::cli_abort("{.arg isolates} should not be given for graph literals") } @@ -34,12 +44,17 @@ graph <- function(edges, ..., n = max(edges), isolates = NULL, directed = TRUE, if (!missing(dir) && missing(directed)) directed <- dir if (is.character(edges) && length(edges) == 1) { - if (!missing(n)) cli::cli_warn("{.arg n} is ignored for the {.str {edges}} graph.") + if (!missing(n)) + cli::cli_warn("{.arg n} is ignored for the {.str {edges}} graph.") if (!missing(isolates)) { - cli::cli_warn("{.arg isolates} is ignored for the {.str {edges}} graph.") + cli::cli_warn( + "{.arg isolates} is ignored for the {.str {edges}} graph." + ) } if (!missing(directed)) { - cli::cli_warn("{.arg directed} is ignored for the {.str {edges}} graph.") + cli::cli_warn( + "{.arg directed} is ignored for the {.str {edges}} graph." + ) } if (!missing(dir)) { cli::cli_warn("{.arg dir} is ignored for the {.str {edges}} graph") @@ -49,8 +64,11 @@ graph <- function(edges, ..., n = max(edges), isolates = NULL, directed = TRUE, make_famous_graph(edges) ## NULL and empty logical vector is allowed for compatibility - } else if (is.numeric(edges) || is.null(edges) || - (is.logical(edges) && length(edges) == 0)) { + } else if ( + is.numeric(edges) || + is.null(edges) || + (is.logical(edges) && length(edges) == 0) + ) { if (is.null(edges) || is.logical(edges)) edges <- as.numeric(edges) if (!is.null(isolates)) { cli::cli_warn("{.arg isolates} ignored for numeric edge list.") @@ -62,7 +80,9 @@ graph <- function(edges, ..., n = max(edges), isolates = NULL, directed = TRUE, n <- 0 } .Call( - R_igraph_create, as.numeric(edges) - 1, as.numeric(n), + R_igraph_create, + as.numeric(edges) - 1, + as.numeric(n), as.logical(directed) ) } @@ -101,10 +121,20 @@ graph <- function(edges, ..., n = max(edges), isolates = NULL, directed = TRUE, #' @inheritParams make_graph #' @keywords internal #' @export -graph.famous <- function(edges, ..., n = max(edges), isolates = NULL, directed = TRUE, dir = directed, simplify = TRUE) { # nocov start +graph.famous <- function( + edges, + ..., + n = max(edges), + isolates = NULL, + directed = TRUE, + dir = directed, + simplify = TRUE +) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.famous()", "make_graph()") if (inherits(edges, "formula")) { - if (!missing(n)) cli::cli_abort("{.arg n} should not be given for graph literals") + if (!missing(n)) + cli::cli_abort("{.arg n} should not be given for graph literals") if (!missing(isolates)) { cli::cli_abort("{.arg isolates} should not be given for graph literals") } @@ -127,12 +157,17 @@ graph.famous <- function(edges, ..., n = max(edges), isolates = NULL, directed = if (!missing(dir) && missing(directed)) directed <- dir if (is.character(edges) && length(edges) == 1) { - if (!missing(n)) cli::cli_warn("{.arg n} is ignored for the {.str {edges}} graph.") + if (!missing(n)) + cli::cli_warn("{.arg n} is ignored for the {.str {edges}} graph.") if (!missing(isolates)) { - cli::cli_warn("{.arg isolates} is ignored for the {.str {edges}} graph.") + cli::cli_warn( + "{.arg isolates} is ignored for the {.str {edges}} graph." + ) } if (!missing(directed)) { - cli::cli_warn("{.arg directed} is ignored for the {.str {edges}} graph.") + cli::cli_warn( + "{.arg directed} is ignored for the {.str {edges}} graph." + ) } if (!missing(dir)) { cli::cli_warn("{.arg dir} is ignored for the {.str {edges}} graph.") @@ -142,8 +177,11 @@ graph.famous <- function(edges, ..., n = max(edges), isolates = NULL, directed = make_famous_graph(edges) ## NULL and empty logical vector is allowed for compatibility - } else if (is.numeric(edges) || is.null(edges) || - (is.logical(edges) && length(edges) == 0)) { + } else if ( + is.numeric(edges) || + is.null(edges) || + (is.logical(edges) && length(edges) == 0) + ) { if (is.null(edges) || is.logical(edges)) edges <- as.numeric(edges) if (!is.null(isolates)) { cli::cli_warn("{.arg isolates} ignored for numeric edge list.") @@ -155,7 +193,9 @@ graph.famous <- function(edges, ..., n = max(edges), isolates = NULL, directed = n <- 0 } .Call( - R_igraph_create, as.numeric(edges) - 1, as.numeric(n), + R_igraph_create, + as.numeric(edges) - 1, + as.numeric(n), as.logical(directed) ) } @@ -194,7 +234,8 @@ graph.famous <- function(edges, ..., n = max(edges), isolates = NULL, directed = #' @inheritParams make_line_graph #' @keywords internal #' @export -line.graph <- function(graph) { # nocov start +line.graph <- function(graph) { + # nocov start lifecycle::deprecate_soft("2.1.0", "line.graph()", "make_line_graph()") ensure_igraph(graph) @@ -216,12 +257,16 @@ line.graph <- function(graph) { # nocov start #' @inheritParams make_ring #' @keywords internal #' @export -graph.ring <- function(n, directed = FALSE, mutual = FALSE, circular = TRUE) { # nocov start +graph.ring <- function(n, directed = FALSE, mutual = FALSE, circular = TRUE) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.ring()", "make_ring()") on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_ring, as.numeric(n), as.logical(directed), - as.logical(mutual), as.logical(circular) + R_igraph_ring, + as.numeric(n), + as.logical(directed), + as.logical(mutual), + as.logical(circular) ) if (igraph_opt("add.params")) { res$name <- "Ring graph" @@ -241,18 +286,17 @@ graph.ring <- function(n, directed = FALSE, mutual = FALSE, circular = TRUE) { # #' @inheritParams make_tree #' @keywords internal #' @export -graph.tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { # nocov start +graph.tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.tree()", "make_tree()") mode <- igraph.match.arg(mode) - mode1 <- switch(mode, - "out" = 0, - "in" = 1, - "undirected" = 2 - ) + mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2) on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_kary_tree, as.numeric(n), as.numeric(children), + R_igraph_kary_tree, + as.numeric(n), + as.numeric(children), as.numeric(mode1) ) if (igraph_opt("add.params")) { @@ -273,27 +317,25 @@ graph.tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { # #' @inheritParams make_star #' @keywords internal #' @export -graph.star <- function(n, mode = c("in", "out", "mutual", "undirected"), center = 1) { # nocov start +graph.star <- function( + n, + mode = c("in", "out", "mutual", "undirected"), + center = 1 +) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.star()", "make_star()") mode <- igraph.match.arg(mode) - mode1 <- switch(mode, - "out" = 0, - "in" = 1, - "undirected" = 2, - "mutual" = 3 - ) + mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2, "mutual" = 3) on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_star, as.numeric(n), as.numeric(mode1), + R_igraph_star, + as.numeric(n), + as.numeric(mode1), as.numeric(center) - 1 ) if (igraph_opt("add.params")) { - res$name <- switch(mode, - "in" = "In-star", - "out" = "Out-star", - "Star" - ) + res$name <- switch(mode, "in" = "In-star", "out" = "Out-star", "Star") res$mode <- mode res$center <- center } @@ -310,7 +352,8 @@ graph.star <- function(n, mode = c("in", "out", "mutual", "undirected"), center #' @inheritParams graph_from_lcf #' @keywords internal #' @export -graph.lcf <- function(n, shifts, repeats = 1) { # nocov start +graph.lcf <- function(n, shifts, repeats = 1) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.lcf()", "graph_from_lcf()") # Argument checks n <- as.numeric(n) @@ -339,7 +382,17 @@ graph.lcf <- function(n, shifts, repeats = 1) { # nocov start #' @keywords internal #' @export #' @cdocs igraph_square_lattice -graph.lattice <- function(dimvector = NULL, length = NULL, dim = NULL, nei = 1, directed = FALSE, mutual = FALSE, periodic = FALSE, circular = deprecated()) { # nocov start +graph.lattice <- function( + dimvector = NULL, + length = NULL, + dim = NULL, + nei = 1, + directed = FALSE, + mutual = FALSE, + periodic = FALSE, + circular = deprecated() +) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.lattice()", "make_lattice()") if (is.numeric(length) && length != floor(length)) { cli::cli_warn("{.arg length} was rounded to the nearest integer.") @@ -390,7 +443,8 @@ graph.lattice <- function(dimvector = NULL, length = NULL, dim = NULL, nei = 1, #' @inheritParams make_kautz_graph #' @keywords internal #' @export -graph.kautz <- function(m, n) { # nocov start +graph.kautz <- function(m, n) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.kautz()", "make_kautz_graph()") on.exit(.Call(R_igraph_finalizer)) res <- .Call(R_igraph_kautz, as.numeric(m), as.numeric(n)) @@ -412,8 +466,13 @@ graph.kautz <- function(m, n) { # nocov start #' @inheritParams make_full_citation_graph #' @keywords internal #' @export -graph.full.citation <- function(n, directed = TRUE) { # nocov start - lifecycle::deprecate_soft("2.1.0", "graph.full.citation()", "make_full_citation_graph()") +graph.full.citation <- function(n, directed = TRUE) { + # nocov start + lifecycle::deprecate_soft( + "2.1.0", + "graph.full.citation()", + "make_full_citation_graph()" + ) # Argument checks n <- as.numeric(n) directed <- as.logical(directed) @@ -436,12 +495,23 @@ graph.full.citation <- function(n, directed = TRUE) { # nocov start #' @inheritParams make_full_bipartite_graph #' @keywords internal #' @export -graph.full.bipartite <- function(n1, n2, directed = FALSE, mode = c("all", "out", "in")) { # nocov start - lifecycle::deprecate_soft("2.1.0", "graph.full.bipartite()", "make_full_bipartite_graph()") +graph.full.bipartite <- function( + n1, + n2, + directed = FALSE, + mode = c("all", "out", "in") +) { + # nocov start + lifecycle::deprecate_soft( + "2.1.0", + "graph.full.bipartite()", + "make_full_bipartite_graph()" + ) n1 <- as.numeric(n1) n2 <- as.numeric(n2) directed <- as.logical(directed) - mode1 <- switch(igraph.match.arg(mode), + mode1 <- switch( + igraph.match.arg(mode), "out" = 1, "in" = 2, "all" = 3, @@ -469,11 +539,14 @@ graph.full.bipartite <- function(n1, n2, directed = FALSE, mode = c("all", "out" #' @inheritParams make_full_graph #' @keywords internal #' @export -graph.full <- function(n, directed = FALSE, loops = FALSE) { # nocov start +graph.full <- function(n, directed = FALSE, loops = FALSE) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.full()", "make_full_graph()") on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_full, as.numeric(n), as.logical(directed), + R_igraph_full, + as.numeric(n), + as.logical(directed), as.logical(loops) ) if (igraph_opt("add.params")) { @@ -493,7 +566,8 @@ graph.full <- function(n, directed = FALSE, loops = FALSE) { # nocov start #' @inheritParams graph_from_literal #' @keywords internal #' @export -graph.formula <- function(..., simplify = TRUE) { # nocov start +graph.formula <- function(..., simplify = TRUE) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.formula()", "graph_from_literal()") mf <- as.list(match.call())[-1] graph_from_literal_i(mf) @@ -509,12 +583,19 @@ graph.formula <- function(..., simplify = TRUE) { # nocov start #' @inheritParams make_chordal_ring #' @keywords internal #' @export -graph.extended.chordal.ring <- function(n, w, directed = FALSE) { # nocov start - lifecycle::deprecate_soft("2.1.0", "graph.extended.chordal.ring()", "make_chordal_ring()") +graph.extended.chordal.ring <- function(n, w, directed = FALSE) { + # nocov start + lifecycle::deprecate_soft( + "2.1.0", + "graph.extended.chordal.ring()", + "make_chordal_ring()" + ) on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_extended_chordal_ring, as.numeric(n), - as.matrix(w), as.logical(directed) + R_igraph_extended_chordal_ring, + as.numeric(n), + as.matrix(w), + as.logical(directed) ) if (igraph_opt("add.params")) { res$name <- "Extended chordal ring" @@ -533,7 +614,8 @@ graph.extended.chordal.ring <- function(n, w, directed = FALSE) { # nocov start #' @inheritParams make_empty_graph #' @keywords internal #' @export -graph.empty <- function(n = 0, directed = TRUE) { # nocov start +graph.empty <- function(n = 0, directed = TRUE) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.empty()", "make_empty_graph()") # Argument checks n <- as.numeric(n) @@ -556,8 +638,13 @@ graph.empty <- function(n = 0, directed = TRUE) { # nocov start #' @inheritParams make_de_bruijn_graph #' @keywords internal #' @export -graph.de.bruijn <- function(m, n) { # nocov start - lifecycle::deprecate_soft("2.1.0", "graph.de.bruijn()", "make_de_bruijn_graph()") +graph.de.bruijn <- function(m, n) { + # nocov start + lifecycle::deprecate_soft( + "2.1.0", + "graph.de.bruijn()", + "make_de_bruijn_graph()" + ) on.exit(.Call(R_igraph_finalizer)) res <- .Call(R_igraph_de_bruijn, as.numeric(m), as.numeric(n)) if (igraph_opt("add.params")) { @@ -578,17 +665,26 @@ graph.de.bruijn <- function(m, n) { # nocov start #' @inheritParams make_bipartite_graph #' @keywords internal #' @export -graph.bipartite <- function(types, edges, directed = FALSE) { # nocov start - lifecycle::deprecate_soft("2.1.0", "graph.bipartite()", "make_bipartite_graph()") +graph.bipartite <- function(types, edges, directed = FALSE) { + # nocov start + lifecycle::deprecate_soft( + "2.1.0", + "graph.bipartite()", + "make_bipartite_graph()" + ) vertex.names <- names(types) if (is.character(edges)) { if (is.null(vertex.names)) { - cli::cli_abort("{.arg types} vector must be named when the edge vector contains strings") + cli::cli_abort( + "{.arg types} vector must be named when the edge vector contains strings" + ) } edges <- match(edges, vertex.names) if (any(is.na(edges))) { - cli::cli_abort("edge vector contains a vertex name that is not found in {.arg types}") + cli::cli_abort( + "edge vector contains a vertex name that is not found in {.arg types}" + ) } } @@ -617,7 +713,8 @@ graph.bipartite <- function(types, edges, directed = FALSE) { # nocov start #' @inheritParams graph_from_atlas #' @keywords internal #' @export -graph.atlas <- function(n) { # nocov start +graph.atlas <- function(n) { + # nocov start lifecycle::deprecate_soft("2.1.0", "graph.atlas()", "graph_from_atlas()") on.exit(.Call(R_igraph_finalizer)) res <- .Call(R_igraph_atlas, as.numeric(n)) @@ -674,7 +771,9 @@ graph.atlas <- function(n) { # nocov start cli::cli_abort("Don't know how to { .operation }, nothing given") } if (sum(cidx) > 1) { - cli::cli_abort("Don't know how to { .operation }, multiple constructors given") + cli::cli_abort( + "Don't know how to { .operation }, multiple constructors given" + ) } cons <- args[cidx][[1]] args <- args[!cidx] @@ -803,7 +902,11 @@ graph.atlas <- function(n) { # nocov start #' @family constructor modifiers make_ <- function(...) { me <- attr(sys.function(), "name") %||% "construct" - extracted <- .extract_constructor_and_modifiers(..., .operation = me, .variant = "make") + extracted <- .extract_constructor_and_modifiers( + ..., + .operation = me, + .variant = "make" + ) cons <- extracted$cons if (cons$lazy) { @@ -859,7 +962,11 @@ make_ <- function(...) { #' @family constructor modifiers sample_ <- function(...) { me <- attr(sys.function(), "name") %||% "construct" - extracted <- .extract_constructor_and_modifiers(..., .operation = me, .variant = "sample") + extracted <- .extract_constructor_and_modifiers( + ..., + .operation = me, + .variant = "sample" + ) cons <- extracted$cons if (cons$lazy) { @@ -896,7 +1003,11 @@ graph_ <- function(...) { ) ) me <- attr(sys.function(), "name") %||% "construct" - extracted <- .extract_constructor_and_modifiers(..., .operation = me, .variant = "graph") + extracted <- .extract_constructor_and_modifiers( + ..., + .operation = me, + .variant = "graph" + ) cons <- extracted$cons if (cons$lazy) { @@ -1072,7 +1183,6 @@ with_graph_ <- function(...) { } - ## ----------------------------------------------------------------- #' Create an igraph graph from a list of edges, or a notable graph @@ -1230,10 +1340,18 @@ with_graph_ <- function(...) { #' B - F, E - J, C - I, L - T, O - T, M - S, #' C - P, C - L, I - L, I - P #' ) -make_graph <- function(edges, ..., n = max(edges), isolates = NULL, - directed = TRUE, dir = directed, simplify = TRUE) { +make_graph <- function( + edges, + ..., + n = max(edges), + isolates = NULL, + directed = TRUE, + dir = directed, + simplify = TRUE +) { if (inherits(edges, "formula")) { - if (!missing(n)) cli::cli_abort("{.arg n} should not be given for graph literals") + if (!missing(n)) + cli::cli_abort("{.arg n} should not be given for graph literals") if (!missing(isolates)) { cli::cli_abort("{.arg isolates} should not be given for graph literals") } @@ -1256,12 +1374,17 @@ make_graph <- function(edges, ..., n = max(edges), isolates = NULL, if (!missing(dir) && missing(directed)) directed <- dir if (is.character(edges) && length(edges) == 1) { - if (!missing(n)) cli::cli_warn("{.arg n} is ignored for the {.str {edges}} graph.") + if (!missing(n)) + cli::cli_warn("{.arg n} is ignored for the {.str {edges}} graph.") if (!missing(isolates)) { - cli::cli_warn("{.arg isolates} is ignored for the {.str {edges}} graph.") + cli::cli_warn( + "{.arg isolates} is ignored for the {.str {edges}} graph." + ) } if (!missing(directed)) { - cli::cli_warn("{.arg directed} is ignored for the {.str {edges}} graph.") + cli::cli_warn( + "{.arg directed} is ignored for the {.str {edges}} graph." + ) } if (!missing(dir)) { cli::cli_warn("{.arg dir} is ignored for the {.str {edges}} graph.") @@ -1271,8 +1394,11 @@ make_graph <- function(edges, ..., n = max(edges), isolates = NULL, make_famous_graph(edges) ## NULL and empty logical vector is allowed for compatibility - } else if (is.numeric(edges) || is.null(edges) || - (is.logical(edges) && length(edges) == 0)) { + } else if ( + is.numeric(edges) || + is.null(edges) || + (is.logical(edges) && length(edges) == 0) + ) { if (is.null(edges) || is.logical(edges)) edges <- as.numeric(edges) if (!is.null(isolates)) { cli::cli_warn("{.arg isolates} ignored for numeric edge list.") @@ -1284,7 +1410,9 @@ make_graph <- function(edges, ..., n = max(edges), isolates = NULL, n <- 0 } .Call( - R_igraph_create, as.numeric(edges) - 1, as.numeric(n), + R_igraph_create, + as.numeric(edges) - 1, + as.numeric(n), as.logical(directed) ) } @@ -1314,7 +1442,7 @@ make_graph <- function(edges, ..., n = max(edges), isolates = NULL, } make_famous_graph <- function(name) { - assert_character(name) + check_string(name) name <- gsub("\\s", "_", name) on.exit(.Call(R_igraph_finalizer)) @@ -1373,7 +1501,9 @@ make_empty_graph <- function(n = 0, directed = TRUE) { cli::cli_abort("{.arg n} must be numeric, not {.obj_type_friendly {n}}.") } if (!is.logical(directed)) { - cli::cli_abort("{.arg directed} must be a logical, not {.obj_type_friendly {directed}}.") + cli::cli_abort( + "{.arg directed} must be a logical, not {.obj_type_friendly {directed}}." + ) } empty_impl(n, directed) } @@ -1385,7 +1515,6 @@ empty_graph <- function(...) constructor_spec(make_empty_graph, ...) ## ----------------------------------------------------------------- - #' Creating (small) graphs via a simple interface #' #' This function is useful if you want to create a small (named) graph @@ -1633,27 +1762,23 @@ from_literal <- function(...) { #' @examples #' make_star(10, mode = "out") #' make_star(5, mode = "undirected") -make_star <- function(n, mode = c("in", "out", "mutual", "undirected"), - center = 1) { +make_star <- function( + n, + mode = c("in", "out", "mutual", "undirected"), + center = 1 +) { mode <- igraph.match.arg(mode) - mode1 <- switch(mode, - "out" = 0, - "in" = 1, - "undirected" = 2, - "mutual" = 3 - ) + mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2, "mutual" = 3) on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_star, as.numeric(n), as.numeric(mode1), + R_igraph_star, + as.numeric(n), + as.numeric(mode1), as.numeric(center) - 1 ) if (igraph_opt("add.params")) { - res$name <- switch(mode, - "in" = "In-star", - "out" = "Out-star", - "Star" - ) + res$name <- switch(mode, "in" = "In-star", "out" = "Out-star", "Star") res$mode <- mode res$center <- center } @@ -1683,7 +1808,9 @@ star <- function(...) constructor_spec(make_star, ...) make_full_graph <- function(n, directed = FALSE, loops = FALSE) { on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_full, as.numeric(n), as.logical(directed), + R_igraph_full, + as.numeric(n), + as.logical(directed), as.logical(loops) ) if (igraph_opt("add.params")) { @@ -1731,9 +1858,16 @@ full_graph <- function(...) constructor_spec(make_full_graph, ...) #' make_lattice(c(5, 5, 5)) #' make_lattice(length = 5, dim = 3) #' @cdocs igraph_square_lattice -make_lattice <- function(dimvector = NULL, length = NULL, dim = NULL, - nei = 1, directed = FALSE, mutual = FALSE, - periodic = FALSE, circular = deprecated()) { +make_lattice <- function( + dimvector = NULL, + length = NULL, + dim = NULL, + nei = 1, + directed = FALSE, + mutual = FALSE, + periodic = FALSE, + circular = deprecated() +) { if (lifecycle::is_present(circular)) { lifecycle::deprecate_soft( "2.0.3", @@ -1797,8 +1931,11 @@ lattice <- function(...) constructor_spec(make_lattice, ...) make_ring <- function(n, directed = FALSE, mutual = FALSE, circular = TRUE) { on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_ring, as.numeric(n), as.logical(directed), - as.logical(mutual), as.logical(circular) + R_igraph_ring, + as.numeric(n), + as.logical(directed), + as.logical(mutual), + as.logical(circular) ) if (igraph_opt("add.params")) { res$name <- "Ring graph" @@ -1838,15 +1975,13 @@ ring <- function(...) constructor_spec(make_ring, ...) #' make_tree(10, 3, mode = "undirected") make_tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { mode <- igraph.match.arg(mode) - mode1 <- switch(mode, - "out" = 0, - "in" = 1, - "undirected" = 2 - ) + mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2) on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_kary_tree, as.numeric(n), as.numeric(children), + R_igraph_kary_tree, + as.numeric(n), + as.numeric(children), as.numeric(mode1) ) if (igraph_opt("add.params")) { @@ -1889,7 +2024,8 @@ sample_tree <- tree_game_impl #' @rdname make_tree #' @param ... Passed to `make_tree()` or `sample_tree()`. #' @export -tree <- function(...) constructor_spec(list(make = make_tree, sample = sample_tree), ...) +tree <- function(...) + constructor_spec(list(make = make_tree, sample = sample_tree), ...) ## ----------------------------------------------------------------- @@ -2000,8 +2136,10 @@ atlas <- function(...) constructor_spec(graph_from_atlas, ...) make_chordal_ring <- function(n, w, directed = FALSE) { on.exit(.Call(R_igraph_finalizer)) res <- .Call( - R_igraph_extended_chordal_ring, as.numeric(n), - as.matrix(w), as.logical(directed) + R_igraph_extended_chordal_ring, + as.numeric(n), + as.matrix(w), + as.logical(directed) ) if (igraph_opt("add.params")) { res$name <- "Extended chordal ring" @@ -2187,12 +2325,17 @@ kautz_graph <- function(...) constructor_spec(make_kautz_graph, ...) #' g4 <- make_full_bipartite_graph(2, 3, directed = TRUE, mode = "all") #' #' @export -make_full_bipartite_graph <- function(n1, n2, directed = FALSE, - mode = c("all", "out", "in")) { +make_full_bipartite_graph <- function( + n1, + n2, + directed = FALSE, + mode = c("all", "out", "in") +) { n1 <- as.numeric(n1) n2 <- as.numeric(n2) directed <- as.logical(directed) - mode1 <- switch(igraph.match.arg(mode), + mode1 <- switch( + igraph.match.arg(mode), "out" = 1, "in" = 2, "all" = 3, @@ -2213,7 +2356,8 @@ make_full_bipartite_graph <- function(n1, n2, directed = FALSE, #' @rdname make_full_bipartite_graph #' @param ... Passed to `make_full_bipartite_graph()`. #' @export -full_bipartite_graph <- function(...) constructor_spec(make_full_bipartite_graph, ...) +full_bipartite_graph <- function(...) + constructor_spec(make_full_bipartite_graph, ...) ## ----------------------------------------------------------------- @@ -2263,11 +2407,15 @@ make_bipartite_graph <- function(types, edges, directed = FALSE) { if (is.character(edges)) { if (is.null(vertex.names)) { - cli::cli_abort("{.arg types} vector must be named when the edge vector contains strings") + cli::cli_abort( + "{.arg types} vector must be named when the edge vector contains strings" + ) } edges <- match(edges, vertex.names) if (any(is.na(edges))) { - cli::cli_abort("edge vector contains a vertex name that is not found in {.arg types}") + cli::cli_abort( + "edge vector contains a vertex name that is not found in {.arg types}" + ) } } @@ -2323,7 +2471,8 @@ make_full_citation_graph <- function(n, directed = TRUE) { #' @rdname make_full_citation_graph #' @param ... Passed to `make_full_citation_graph()`. #' @export -full_citation_graph <- function(...) constructor_spec(make_full_citation_graph, ...) +full_citation_graph <- function(...) + constructor_spec(make_full_citation_graph, ...) ## ----------------------------------------------------------------- @@ -2492,14 +2641,19 @@ realize_degseq <- realize_degree_sequence_impl #' g <- realize_bipartite_degseq(c(3, 3, 2, 1, 1), c(2, 2, 2, 2, 2)) #' degree(g) #' @cdocs igraph_realize_bipartite_degree_sequence -realize_bipartite_degseq <- function(degrees1, degrees2, ..., - allowed.edge.types = c("simple", "multiple"), - method = c("smallest", "largest", "index")) { +realize_bipartite_degseq <- function( + degrees1, + degrees2, + ..., + allowed.edge.types = c("simple", "multiple"), + method = c("smallest", "largest", "index") +) { check_dots_empty() allowed.edge.types <- igraph.match.arg(allowed.edge.types) method <- igraph.match.arg(method) g <- realize_bipartite_degree_sequence_impl( - degrees1 = degrees1, degrees2 = degrees2, + degrees1 = degrees1, + degrees2 = degrees2, allowed.edge.types = allowed.edge.types, method = method ) diff --git a/R/utils-assert-character.R b/R/utils-assert-character.R deleted file mode 100644 index adbec55d74e..00000000000 --- a/R/utils-assert-character.R +++ /dev/null @@ -1,7 +0,0 @@ -assert_character <- function(x, name = "name", call = rlang::caller_env()) { - check_string( - x, - arg = name, - call = call - ) -} diff --git a/tests/testthat/_snaps/attributes.md b/tests/testthat/_snaps/attributes.md index c2650441779..c9b916fc2c5 100644 --- a/tests/testthat/_snaps/attributes.md +++ b/tests/testthat/_snaps/attributes.md @@ -54,3 +54,11 @@ Error in `assert_named_list()`: ! `value` must be a named list with unique names +# good error message when not using character + + Code + set_graph_attr(ring, 1, 1) + Condition + Error in `set_graph_attr()`: + ! `name` must be a single string, not the number 1. + diff --git a/tests/testthat/test-attributes.R b/tests/testthat/test-attributes.R index 26183618166..9736d30b062 100644 --- a/tests/testthat/test-attributes.R +++ b/tests/testthat/test-attributes.R @@ -156,19 +156,42 @@ test_that("we can set all attributes on some vertices/edges", { g2 <- make_graph(c(2, 1, 3, 1, 4, 1, 2, 5, 3, 6)) vertex_attr(g2, index = c(1, 2, 4, 5)) <- vertex_attr(g) - expect_equal(vertex_attr(g2), list(name = c( - "a", "b", NA_character_, - "c", "d", NA_character_ - ), color = list( - rainbow(4)[1], rainbow(4)[2], NULL, - rainbow(4)[3], rainbow(4)[4], NULL - ))) + expect_equal( + vertex_attr(g2), + list( + name = c( + "a", + "b", + NA_character_, + "c", + "d", + NA_character_ + ), + color = list( + rainbow(4)[1], + rainbow(4)[2], + NULL, + rainbow(4)[3], + rainbow(4)[4], + NULL + ) + ) + ) edge_attr(g2, index = c(1, 3, 5)) <- edge_attr(g) - expect_equal(edge_attr(g2), list(weight = c( - 1L, NA_integer_, 2L, - NA_integer_, 3L - ), label = list("A", NULL, "B", NULL, "C"))) + expect_equal( + edge_attr(g2), + list( + weight = c( + 1L, + NA_integer_, + 2L, + NA_integer_, + 3L + ), + label = list("A", NULL, "B", NULL, "C") + ) + ) }) test_that("cannot use vs/es from another graph", { @@ -184,8 +207,14 @@ test_that("cannot use vs/es from another graph", { 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")), "invalid 'type'") - expect_error(as_undirected(g, edge.attr.comb = list(weight = sum)), "invalid 'type'") + expect_error( + as_undirected(g, edge.attr.comb = list(weight = "sum")), + "invalid 'type'" + ) + expect_error( + as_undirected(g, edge.attr.comb = list(weight = sum)), + "invalid 'type'" + ) }) test_that("can change type of attributes", { @@ -255,12 +284,18 @@ test_that("assert_named_list() works", { }) test_that("is_bipartite works", { - biadj_mat1 <- matrix(sample(0:1, 35, replace = TRUE, prob = c(3, 1)), ncol = 5) + biadj_mat1 <- matrix( + sample(0:1, 35, replace = TRUE, prob = c(3, 1)), + ncol = 5 + ) g1 <- graph_from_biadjacency_matrix(biadj_mat1) expect_true(bipartite_mapping(g1)$res) withr::local_seed(42) - biadj_mat2 <- matrix(sample(0:1, 35, replace = TRUE, prob = c(3, 1)), ncol = 5) + biadj_mat2 <- matrix( + sample(0:1, 35, replace = TRUE, prob = c(3, 1)), + ncol = 5 + ) g2 <- graph_from_biadjacency_matrix(biadj_mat2) expect_equal( bipartite_mapping(g2), @@ -423,3 +458,10 @@ test_that("assign data.frame attributes works", { edge.attributes(g) <- head(mtcars, ecount(g)) expect_no_error(E(g)[c(1, 2)]) }) + +test_that("good error message when not using character", { + ring <- graph_from_literal(A - B - C - D - E - F - G - A) + expect_snapshot(error = TRUE, { + set_graph_attr(ring, 1, 1) + }) +}) diff --git a/tools/weights.R b/tools/weights.R new file mode 100644 index 00000000000..2fddd1e05eb --- /dev/null +++ b/tools/weights.R @@ -0,0 +1,22 @@ +library(igraph) +library(tidyverse) + +# https://seankross.com/2021/02/25/Analyzing-R-Function-Arguments.html +args_data <- tibble(Package = "package:igraph") %>% + mutate(Function = list(lsf.str(Package))) %>% + unnest(Function) %>% + mutate(Function = as.character(Function)) %>% + mutate( + Arg = map( + Function, + compose(args, as.list, names, ~ keep(.x, nzchar), .dir = "forward") + ) + ) %>% + unnest(Arg, keep_empty = TRUE) + +dplyr::filter(args_data, Arg == "weights") |> + dplyr::mutate(deprecated = grepl("\\.", Function)) |> + dplyr::mutate(arg_def = "") |> + dplyr::mutate(notes = "") |> + dplyr::arrange(deprecated) |> + knitr::kable()