From 3a9ed7967e5173f895b7dad9daa0b5c06a01f153 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 08:11:54 +0000 Subject: [PATCH 01/15] Initial plan From 3937dfcf3ea436093768c995b97704cf06d9f918 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 08:34:50 +0000 Subject: [PATCH 02/15] Add comments explaining why .Call() expressions cannot be replaced with _impl functions Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/attributes.R | 46 +++++++++++++++++++-------------------- R/bipartite.R | 2 +- R/centrality.R | 4 ++-- R/cliques.R | 8 +++---- R/community.R | 14 ++++++------ R/conversion.R | 12 +++++----- R/decomposition.R | 2 +- R/fit.R | 2 +- R/foreign.R | 14 ++++++------ R/games.R | 2 +- R/interface.R | 6 ++--- R/iterators.R | 26 +++++++++++----------- R/layout.R | 20 ++++++++--------- R/operators.R | 12 +++++----- R/par.R | 4 ++-- R/pp.R | 2 +- R/print.R | 6 ++--- R/structural-properties.R | 28 ++++++++++++------------ R/topology.R | 2 +- R/utils.R | 4 ++-- R/uuid.R | 4 ++-- R/versions.R | 16 +++++++------- R/weakref.R | 8 +++---- 23 files changed, 122 insertions(+), 122 deletions(-) diff --git a/R/attributes.R b/R/attributes.R index d45ab8853f0..5b28b7f9ff8 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -328,7 +328,7 @@ graph_attr <- function(graph, name) { check_string(name) - .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ + .Call(Rx_igraph_mybracket2, # no _impl graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ name ]] } @@ -388,7 +388,7 @@ set_graph_attr <- function(graph, name, value) { ensure_igraph(graph) - .Call( + .Call( # no _impl Rx_igraph_mybracket3_set, graph, igraph_t_idx_attr, @@ -401,7 +401,7 @@ set_graph_attr <- function(graph, name, value) { #' @export graph.attributes <- function(graph) { ensure_igraph(graph) - .Call( + .Call( # no _impl Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -417,7 +417,7 @@ graph.attributes <- function(graph) { value <- as.list(value) } - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -459,7 +459,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { check_string(name) myattr <- - .Call( + .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -609,7 +609,7 @@ i_set_vertex_attr <- function( index <- as_igraph_vs(graph, index) } - vattrs <- .Call( + vattrs <- .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -643,7 +643,7 @@ i_set_vertex_attr <- function( } } - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -660,7 +660,7 @@ vertex.attributes <- function(graph, index = V(graph)) { index <- as_igraph_vs(graph, index) } - res <- .Call( + res <- .Call( # no _impl Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -720,7 +720,7 @@ set_value_at <- function(value, idx, length_out) { ) } - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -761,7 +761,7 @@ edge_attr <- function(graph, name, index = E(graph)) { } } else { check_string(name) - myattr <- .Call( + myattr <- .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -865,7 +865,7 @@ i_set_edge_attr <- function( index <- as_igraph_es(graph, index) } - eattrs <- .Call( + eattrs <- .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -896,7 +896,7 @@ i_set_edge_attr <- function( } } - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -913,7 +913,7 @@ edge.attributes <- function(graph, index = E(graph)) { index <- as_igraph_es(graph, index) } - res <- .Call( + res <- .Call( # no _impl Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -963,7 +963,7 @@ edge.attributes <- function(graph, index = E(graph)) { ) } - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -986,7 +986,7 @@ edge.attributes <- function(graph, index = E(graph)) { #' graph_attr_names(g) graph_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1015,7 +1015,7 @@ graph_attr_names <- function(graph) { vertex_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1043,7 +1043,7 @@ vertex_attr_names <- function(graph) { #' plot(g) edge_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1077,7 +1077,7 @@ delete_graph_attr <- function(graph, name) { cli::cli_abort("No graph attribute {.arg {name}} found.") } - gattr <- .Call( + gattr <- .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1085,7 +1085,7 @@ delete_graph_attr <- function(graph, name) { ) gattr[[name]] <- NULL - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -1117,7 +1117,7 @@ delete_vertex_attr <- function(graph, name) { cli::cli_abort("No vertex attribute {.arg {name}} found.") } - vattr <- .Call( + vattr <- .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1125,7 +1125,7 @@ delete_vertex_attr <- function(graph, name) { ) vattr[[name]] <- NULL - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -1157,7 +1157,7 @@ delete_edge_attr <- function(graph, name) { cli::cli_abort("No edge attribute {.arg {name}} found.") } - eattr <- .Call( + eattr <- .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1165,7 +1165,7 @@ delete_edge_attr <- function(graph, name) { ) eattr[[name]] <- NULL - .Call( + .Call( # no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, diff --git a/R/bipartite.R b/R/bipartite.R index c5cabb23870..3444916b015 100644 --- a/R/bipartite.R +++ b/R/bipartite.R @@ -190,7 +190,7 @@ bipartite_projection <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( + res <- .Call( # no _impl Rx_igraph_bipartite_projection, graph, types, diff --git a/R/centrality.R b/R/centrality.R index a017fa35907..419fc348424 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -992,7 +992,7 @@ arpack <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_arpack, func, extra, options, env, sym) + res <- .Call(Rx_igraph_arpack, func, extra, options, env, sym) # no _impl if (complex) { rew <- arpack.unpack.complex( @@ -1030,7 +1030,7 @@ arpack.unpack.complex <- function(vectors, values, nev) { on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call(Rx_igraph_arpack_unpack_complex, vectors, values, nev) + res <- .Call(Rx_igraph_arpack_unpack_complex, vectors, values, nev) # no _impl res } diff --git a/R/cliques.R b/R/cliques.R index fe3a85f0c35..9bae58314c6 100644 --- a/R/cliques.R +++ b/R/cliques.R @@ -325,7 +325,7 @@ max_cliques <- function( tmpfile <- FALSE } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_maximal_cliques_file, graph, subset, @@ -350,7 +350,7 @@ max_cliques <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_maximal_cliques, graph, subset_arg, @@ -403,7 +403,7 @@ count_max_cliques <- function(graph, min = NULL, max = NULL, subset = NULL) { on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call(Rx_igraph_maximal_cliques_count, graph, subset, min, max) + res <- .Call(Rx_igraph_maximal_cliques_count, graph, subset, min, max) # maximal_cliques_count_impl() has no subset argument res } @@ -579,7 +579,7 @@ ivs <- function(graph, min = NULL, max = NULL) { } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_independent_vertex_sets, graph, as.numeric(min), diff --git a/R/community.R b/R/community.R index 3fdc0df6ec4..b2c32d495d1 100644 --- a/R/community.R +++ b/R/community.R @@ -1315,7 +1315,7 @@ community.to.membership2 <- function(merges, vcount, steps) { mode(vcount) <- "numeric" mode(steps) <- "numeric" on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_community_to_membership2, merges - 1, vcount, steps) + res <- .Call(Rx_igraph_community_to_membership2, merges - 1, vcount, steps) # no _impl res + 1 } @@ -1480,7 +1480,7 @@ cluster_spinglass <- function( on.exit(.Call(Rx_igraph_finalizer)) if (is.null(vertex) || length(vertex) == 0) { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_spinglass_community, graph, weights, @@ -1502,7 +1502,7 @@ cluster_spinglass <- function( } class(res) <- "communities" } else { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_spinglass_my_community, graph, weights, @@ -1858,7 +1858,7 @@ cluster_walktrap <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_walktrap_community, graph, weights, @@ -1986,7 +1986,7 @@ cluster_edge_betweenness <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_community_edge_betweenness, graph, weights, @@ -2078,7 +2078,7 @@ cluster_fast_greedy <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_community_fastgreedy, graph, as.logical(merges), @@ -2100,7 +2100,7 @@ cluster_fast_greedy <- function( igraph.i.levc.arp <- function(externalP, externalE) { f <- function(v) { v <- as.numeric(v) - .Call(R_igraph_levc_arpack_multiplier, externalP, externalE, v) + .Call(R_igraph_levc_arpack_multiplier, externalP, externalE, v) # no _impl } f } diff --git a/R/conversion.R b/R/conversion.R index 0d73ec08d54..b7bb5570362 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -656,7 +656,7 @@ as_adj_list <- function( multiple <- if (multiple) 1 else 0 on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_get_adjlist, graph, mode, loops, multiple) + res <- .Call(Rx_igraph_get_adjlist, graph, mode, loops, multiple) # no _impl res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) @@ -686,7 +686,7 @@ as_adj_edge_list <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) + res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) # no _impl res <- lapply(res, function(.x) E(graph)[.x + 1]) if (is_named(graph)) { names(res) <- V(graph)$name @@ -1149,7 +1149,7 @@ as_data_frame <- function(x, what = c("edges", "vertices", "both")) { what <- igraph_match_arg(what) if (what %in% c("vertices", "both")) { - ver <- .Call( + ver <- .Call( # no _impl Rx_igraph_mybracket2, x, igraph_t_idx_attr, @@ -1168,7 +1168,7 @@ as_data_frame <- function(x, what = c("edges", "vertices", "both")) { el <- as_edgelist(x) edg <- c( list(from = el[, 1], to = el[, 2]), - .Call(Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) + .Call(Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) # no _impl ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(x)) @@ -1274,7 +1274,7 @@ graph_from_adj_list <- function( as_long_data_frame <- function(graph) { ensure_igraph(graph) - ver <- .Call( + ver <- .Call( # no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1292,7 +1292,7 @@ as_long_data_frame <- function(graph) { edg <- c( list(from = el[, 1]), list(to = el[, 2]), - .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) # no _impl ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(graph)) diff --git a/R/decomposition.R b/R/decomposition.R index 8c8e92b570c..8004d96ab63 100644 --- a/R/decomposition.R +++ b/R/decomposition.R @@ -133,7 +133,7 @@ is_chordal <- function( fillin <- as.logical(fillin) newgraph <- as.logical(newgraph) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_is_chordal, graph, alpha, diff --git a/R/fit.R b/R/fit.R index e0849b32a4c..ab497276002 100644 --- a/R/fit.R +++ b/R/fit.R @@ -266,7 +266,7 @@ power.law.fit.new <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( + res <- .Call( # no _impl Rx_igraph_power_law_fit_new, data, xmin, diff --git a/R/foreign.R b/R/foreign.R index 57a927759cd..119b21e6135 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -525,7 +525,7 @@ write_graph <- function( read.graph.edgelist <- function(file, n = 0, directed = TRUE) { on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_read_graph_edgelist, file, as.numeric(n), @@ -558,7 +558,7 @@ read.graph.ncol <- function( "auto" = 2L ) on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_read_graph_ncol, file, as.character(predef), @@ -584,7 +584,7 @@ write.graph.ncol <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_write_graph_ncol, graph, file, @@ -606,7 +606,7 @@ read.graph.lgl <- function( "auto" = 2L ) on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_read_graph_lgl, file, as.logical(names), @@ -632,7 +632,7 @@ write.graph.lgl <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_write_graph_lgl, graph, file, @@ -662,7 +662,7 @@ write.graph.pajek <- function(graph, file) { } read.graph.dimacs <- function(file, directed = TRUE) { - res <- .Call(Rx_igraph_read_graph_dimacs, file, as.logical(directed)) + res <- .Call(Rx_igraph_read_graph_dimacs, file, as.logical(directed)) # no _impl if (res[[1]][1] == "max") { graph <- res[[2]] graph <- set_graph_attr(graph, "problem", res[[1]]) @@ -696,7 +696,7 @@ write.graph.dimacs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_write_graph_dimacs, graph, file, diff --git a/R/games.R b/R/games.R index dd72d790b03..e241d87e87b 100644 --- a/R/games.R +++ b/R/games.R @@ -1933,7 +1933,7 @@ traits <- function( #' sample_grg <- function(nodes, radius, torus = FALSE, coords = FALSE) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_grg_game, as.double(nodes), as.double(radius), diff --git a/R/interface.R b/R/interface.R index f1f1f3b0f5e..4b25dfe9130 100644 --- a/R/interface.R +++ b/R/interface.R @@ -151,7 +151,7 @@ add_edges <- function(graph, edges, ..., attr = list()) { edges.orig <- ecount(graph) on.exit(.Call(Rx_igraph_finalizer)) - graph <- .Call( + graph <- .Call( # no _impl Rx_igraph_add_edges_manual, graph, as_igraph_vs(graph, edges) - 1 @@ -639,7 +639,7 @@ adjacent_vertices <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_adjacent_vertices, graph, vv, mode) + res <- .Call(Rx_igraph_adjacent_vertices, graph, vv, mode) # no _impl res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -676,7 +676,7 @@ incident_edges <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_incident_edges, graph, vv, mode) + res <- .Call(Rx_igraph_incident_edges, graph, vv, mode) # no _impl res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { diff --git a/R/iterators.R b/R/iterators.R index cfde92bebd6..76ae4a35e51 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -30,7 +30,7 @@ update_es_ref <- update_vs_ref <- function(graph) { get_es_ref <- get_vs_ref <- function(graph) { if (is_igraph(graph) && !warn_version(graph)) { - .Call(Rx_igraph_copy_env, graph) + .Call(Rx_igraph_copy_env, graph) # no _impl } else { NULL } @@ -84,7 +84,7 @@ get_es_graph_id <- get_vs_graph_id <- function(seq) { #' @export identical_graphs <- function(g1, g2, attrs = TRUE) { stopifnot(is_igraph(g1), is_igraph(g2)) - .Call(Rx_igraph_identical_graphs, g1, g2, as.logical(attrs)) + .Call(Rx_igraph_identical_graphs, g1, g2, as.logical(attrs)) # is_same_graph_impl() has no attrs argument } add_vses_graph_ref <- function(vses, graph) { @@ -362,7 +362,7 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { res <- set_complete_iterator(res) } else if (!is.null(P)) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_es_pairs, graph, as_igraph_vs(graph, P) - 1, @@ -371,7 +371,7 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { 1 } else { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_es_path, graph, as_igraph_vs(graph, path) - 1, @@ -590,7 +590,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { v <- which(v) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # no _impl Rx_igraph_vs_nei, graph, x, @@ -621,7 +621,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # no _impl Rx_igraph_vs_adj, graph, x, @@ -642,7 +642,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # no _impl Rx_igraph_vs_adj, graph, x, @@ -660,7 +660,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # no _impl Rx_igraph_vs_adj, graph, x, @@ -983,7 +983,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .inc <- function(v) { ## TRUE iff the edge is incident to at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # no _impl Rx_igraph_es_adj, graph, x, @@ -1001,7 +1001,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .from <- function(v) { ## TRUE iff the edge originates from at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # no _impl Rx_igraph_es_adj, graph, x, @@ -1016,7 +1016,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .to <- function(v) { ## TRUE iff the edge points to at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # no _impl Rx_igraph_es_adj, graph, x, @@ -1061,8 +1061,8 @@ simple_es_index <- function(x, i, na_ok = FALSE) { parent = top, c( attrs, - .igraph.from = list(.Call(Rx_igraph_copy_from, graph)[as.numeric(x)]), - .igraph.to = list(.Call(Rx_igraph_copy_to, graph)[as.numeric(x)]), + .igraph.from = list(.Call(Rx_igraph_copy_from, graph)[as.numeric(x)]), # no _impl + .igraph.to = list(.Call(Rx_igraph_copy_to, graph)[as.numeric(x)]), # no _impl .igraph.graph = list(graph), .env = env, .data = list(attrs) diff --git a/R/layout.R b/R/layout.R index 1f14bbe0fb6..51f1e19efdd 100644 --- a/R/layout.R +++ b/R/layout.R @@ -858,7 +858,7 @@ layout_as_tree <- function( flip.y <- as.logical(flip.y) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_layout_reingold_tilford, graph, root, @@ -1575,7 +1575,7 @@ layout_with_fr <- function( on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_layout_fruchterman_reingold, graph, coords, @@ -1589,7 +1589,7 @@ layout_with_fr <- function( grid ) } else { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_layout_fruchterman_reingold_3d, graph, coords, @@ -1767,7 +1767,7 @@ layout_with_graphopt <- function( max.sa.movement <- as.double(max.sa.movement) on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_layout_graphopt, graph, niter, @@ -1930,7 +1930,7 @@ layout_with_kk <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call if (dim == 2) { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_layout_kamada_kawai, graph, coords, @@ -1944,7 +1944,7 @@ layout_with_kk <- function( maxy ) } else { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_layout_kamada_kawai_3d, graph, coords, @@ -2038,7 +2038,7 @@ layout_with_lgl <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_layout_lgl, graph, as.double(maxiter), @@ -2550,7 +2550,7 @@ merge_coords <- function(graphs, layouts, method = "dla") { } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_layout_merge_dla, graphs, layouts @@ -2893,7 +2893,7 @@ layout_with_drl <- function( on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_layout_drl, graph, seed, @@ -2902,7 +2902,7 @@ layout_with_drl <- function( weights ) } else { - res <- .Call( + res <- .Call( # no _impl Rx_igraph_layout_drl_3d, graph, seed, diff --git a/R/operators.R b/R/operators.R index 002e0128a38..7ab9b8ee0ce 100644 --- a/R/operators.R +++ b/R/operators.R @@ -229,7 +229,7 @@ disjoint_union <- function(...) { lapply(graphs, ensure_igraph) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_disjoint_union, graphs) + res <- .Call(Rx_igraph_disjoint_union, graphs) # disjoint_union_many_impl() exists but returns different structure ## Graph attributes graph.attributes(res) <- rename.attr.if.needed("g", graphs) @@ -350,9 +350,9 @@ disjoint_union <- function(...) { on.exit(.Call(Rx_igraph_finalizer)) if (call == "union") { - res <- .Call(Rx_igraph_union, newgraphs, edgemaps) + res <- .Call(Rx_igraph_union, newgraphs, edgemaps) # union_many_impl() has no edgemaps argument } else { - res <- .Call(Rx_igraph_intersection, newgraphs, edgemaps) + res <- .Call(Rx_igraph_intersection, newgraphs, edgemaps) # intersection_many_impl() has no edgemaps argument } maps <- res$edgemaps res <- res$graph @@ -390,9 +390,9 @@ disjoint_union <- function(...) { on.exit(.Call(Rx_igraph_finalizer)) if (call == "union") { - res <- .Call(Rx_igraph_union, graphs, edgemaps) + res <- .Call(Rx_igraph_union, graphs, edgemaps) # union_many_impl() has no edgemaps argument } else { - res <- .Call(Rx_igraph_intersection, graphs, edgemaps) + res <- .Call(Rx_igraph_intersection, graphs, edgemaps) # intersection_many_impl() has no edgemaps argument } maps <- res$edgemaps res <- res$graph @@ -848,7 +848,7 @@ compose <- function(g1, g2, byname = "auto") { length(edge_attr_names(g2)) != 0) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_compose, g1, g2, edgemaps) + res <- .Call(Rx_igraph_compose, g1, g2, edgemaps) # compose_impl() has no edgemaps argument maps <- list(res$edge_map1, res$edge_map2) res <- res$graph diff --git a/R/par.R b/R/par.R index ac5d3d1c3f8..d062374fda8 100644 --- a/R/par.R +++ b/R/par.R @@ -76,7 +76,7 @@ getIgraphOpt <- function(x, default = NULL) { igraph.pars.set.verbose <- function(verbose) { if (is.logical(verbose)) { - .Call(Rx_igraph_set_verbose, verbose) + .Call(Rx_igraph_set_verbose, verbose) # no _impl } else if (is.character(verbose)) { if (!verbose %in% c("tk", "tkconsole")) { cli::cli_abort("Unknown {.arg verbose} value.") @@ -89,7 +89,7 @@ igraph.pars.set.verbose <- function(verbose) { cli::cli_abort("tcltk package not available.") } } - .Call(Rx_igraph_set_verbose, TRUE) + .Call(Rx_igraph_set_verbose, TRUE) # no _impl } else { cli::cli_abort("{.arg verbose} should be a logical or character scalar.") } diff --git a/R/pp.R b/R/pp.R index a412f1d434a..666bc777a47 100644 --- a/R/pp.R +++ b/R/pp.R @@ -20,5 +20,5 @@ ################################################################### get.all.simple.paths.pp <- function(vect) { - .Call(Rx_igraph_get_all_simple_paths_pp, vect) + .Call(Rx_igraph_get_all_simple_paths_pp, vect) # no _impl } diff --git a/R/print.R b/R/print.R index 243a7d2055d..c676f36e584 100644 --- a/R/print.R +++ b/R/print.R @@ -33,7 +33,7 @@ sep = "", gal, " (g/", - .Call(Rx_igraph_get_attr_mode, object, 2L), + .Call(Rx_igraph_get_attr_mode, object, 2L), # no _impl ")" ) } @@ -43,7 +43,7 @@ sep = "", val, " (v/", - .Call(Rx_igraph_get_attr_mode, object, 3L), + .Call(Rx_igraph_get_attr_mode, object, 3L), # no _impl ")" ) } @@ -53,7 +53,7 @@ sep = "", edge_attr_names(object), " (e/", - .Call(Rx_igraph_get_attr_mode, object, 4L), + .Call(Rx_igraph_get_attr_mode, object, 4L), # no _impl ")" ) } diff --git a/R/structural-properties.R b/R/structural-properties.R index e7c23846e96..ee65ed3dfae 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -768,7 +768,7 @@ diameter <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_diameter, graph, as.logical(directed), @@ -797,7 +797,7 @@ get_diameter <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_get_diameter, graph, as.logical(directed), @@ -833,7 +833,7 @@ farthest_vertices <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_farthest_points, graph, as.logical(directed), @@ -1245,7 +1245,7 @@ distances <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_shortest_paths, graph, v - 1, @@ -1329,7 +1329,7 @@ shortest_paths <- function( to <- as_igraph_vs(graph, to) - 1 on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_get_shortest_paths, graph, as_igraph_vs(graph, from) - 1, @@ -1527,7 +1527,7 @@ subcomponent <- function(graph, v, mode = c("all", "out", "in")) { mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_subcomponent, graph, as_igraph_vs(graph, v) - 1, @@ -1822,7 +1822,7 @@ transitivity <- function( } else if (type == 1) { isolates_num <- as.double(switch(isolates, "nan" = 0, "zero" = 1)) if (is.null(vids)) { - res <- .Call( + res <- .Call( # transitivity_local_undirected_impl() requires vids, no "all" variant Rx_igraph_transitivity_local_undirected_all, graph, isolates_num @@ -2062,7 +2062,7 @@ ego_size <- function( mindist <- as.numeric(mindist) on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # no _impl Rx_igraph_neighborhood_size, graph, as_igraph_vs(graph, nodes) - 1, @@ -2176,7 +2176,7 @@ ego <- function( mindist <- as.numeric(mindist) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_neighborhood, graph, as_igraph_vs(graph, nodes) - 1, @@ -2211,7 +2211,7 @@ make_ego_graph <- function( mindist <- as.numeric(mindist) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_neighborhood_graphs, graph, as_igraph_vs(graph, nodes) - 1, @@ -2452,7 +2452,7 @@ girth <- function(graph, circle = TRUE) { ensure_igraph(graph) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_girth, graph, as.logical(circle)) + res <- .Call(Rx_igraph_girth, graph, as.logical(circle)) # girth_impl() has no circle argument if (res$girth == 0) { res$girth <- Inf } @@ -2768,7 +2768,7 @@ bfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_bfs, graph, root, @@ -3024,7 +3024,7 @@ dfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no _impl Rx_igraph_dfs, graph, root, @@ -3183,7 +3183,7 @@ count_components <- function(graph, mode = c("weak", "strong")) { mode <- switch(mode, "weak" = 1L, "strong" = 2L) on.exit(.Call(Rx_igraph_finalizer)) - .Call(Rx_igraph_no_components, graph, mode) + .Call(Rx_igraph_no_components, graph, mode) # no _impl } #' Count reachable vertices diff --git a/R/topology.R b/R/topology.R index c07d59e785e..61488db16e1 100644 --- a/R/topology.R +++ b/R/topology.R @@ -220,7 +220,7 @@ graph.subisomorphic.lad <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( + res <- .Call( # no _impl Rx_igraph_subisomorphic_lad, pattern, target, diff --git a/R/utils.R b/R/utils.R index d172590cc0d..1dafe63083f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -72,7 +72,7 @@ capitalize <- function(x) { } address <- function(x) { - .Call(Rx_igraph_address, x) + .Call(Rx_igraph_address, x) # no _impl } `%+%` <- function(x, y) { @@ -112,5 +112,5 @@ modify_list <- function(x, y) { #' test_error_with_source() #' } test_error_with_source <- function() { - .Call(Rx_igraph_test_error_with_source) + .Call(Rx_igraph_test_error_with_source) # no _impl } diff --git a/R/uuid.R b/R/uuid.R index b617afeff4f..a6e6385733f 100644 --- a/R/uuid.R +++ b/R/uuid.R @@ -1,11 +1,11 @@ generate_uuid <- function(use_time = NA) { - .Call(UUID_gen, as.logical(use_time)) + .Call(UUID_gen, as.logical(use_time)) # no _impl } get_graph_id <- function(graph) { if (!warn_version(graph)) { - .Call(Rx_igraph_get_graph_id, graph) + .Call(Rx_igraph_get_graph_id, graph) # no _impl } else { NA_character_ } diff --git a/R/versions.R b/R/versions.R index 40b80ac2a12..9a5452444b3 100644 --- a/R/versions.R +++ b/R/versions.R @@ -57,7 +57,7 @@ graph_version <- function(graph) { # Don't call is_igraph() here to avoid recursion stopifnot(inherits(graph, "igraph")) - .Call(Rx_igraph_graph_version, graph) + .Call(Rx_igraph_graph_version, graph) # no _impl } #' igraph data structure versions @@ -99,13 +99,13 @@ upgrade_graph <- function(graph) { # g_ver < p_ver if (g_ver == ver_0_4) { - .Call(Rx_igraph_add_env, graph) + .Call(Rx_igraph_add_env, graph) # no _impl } else if (g_ver == ver_0_7_999) { # Not observed in the wild - .Call(Rx_igraph_add_myid_to_env, graph) - .Call(Rx_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_myid_to_env, graph) # no _impl + .Call(Rx_igraph_add_version_to_env, graph) # no _impl } else if (g_ver == ver_0_8) { - .Call(Rx_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) # no _impl graph <- unclass(graph) graph[igraph_t_idx_oi:igraph_t_idx_is] <- list(NULL) class(graph) <- "igraph" @@ -127,10 +127,10 @@ upgrade_graph <- function(graph) { warn_version <- function(graph) { # Calling for side effect: error if Rz_SEXP_to_igraph() fails # Don't call vcount_impl() to avoid recursion - .Call(Rx_igraph_vcount, graph) + .Call(Rx_igraph_vcount, graph) # vcount_impl() would cause recursion # graph_version() calls is_igraph(), but that function must call warn_version() for safety - their_version <- .Call(Rx_igraph_graph_version, graph) + their_version <- .Call(Rx_igraph_graph_version, graph) # no _impl if (pkg_graph_version == their_version) { return(FALSE) @@ -151,7 +151,7 @@ warn_version <- function(graph) { # Users will have to call upgrade_graph(), but this is what the message # is about. if (pkg_graph_version <= ver_1_5_0) { - .Call(Rx_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) # no _impl } return(TRUE) } diff --git a/R/weakref.R b/R/weakref.R index 45970feeaf1..5f471bee3a2 100644 --- a/R/weakref.R +++ b/R/weakref.R @@ -22,17 +22,17 @@ ## ----------------------------------------------------------------------- make_weak_ref <- function(key, value, finalizer = NULL) { - .Call(Rx_igraph_make_weak_ref, key, value, finalizer) + .Call(Rx_igraph_make_weak_ref, key, value, finalizer) # no _impl } weak_ref_key <- function(ref) { - .Call(Rx_igraph_weak_ref_key, ref) + .Call(Rx_igraph_weak_ref_key, ref) # no _impl } weak_ref_value <- function(ref) { - .Call(Rx_igraph_weak_ref_value, ref) + .Call(Rx_igraph_weak_ref_value, ref) # no _impl } weak_ref_run_finalizer <- function(ref) { - .Call(Rx_igraph_weak_ref_run_finalizer, ref) + .Call(Rx_igraph_weak_ref_run_finalizer, ref) # no _impl } From a85a6982ef77d7edf15f5f1edd76501191350549 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 08:36:18 +0000 Subject: [PATCH 03/15] Fix syntax error in attributes.R comment placement Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/attributes.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/attributes.R b/R/attributes.R index 5b28b7f9ff8..52aac3d2f56 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -328,7 +328,7 @@ graph_attr <- function(graph, name) { check_string(name) - .Call(Rx_igraph_mybracket2, # no _impl graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ # no _impl name ]] } From 330f32673a5c5521724b1ab8ca553699597c1d6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:14:03 +0000 Subject: [PATCH 04/15] Replace .Call() with _impl functions where possible, add explanatory comments elsewhere Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/attributes.R | 46 +++++++-------- R/bipartite.R | 2 +- R/centrality.R | 4 +- R/cliques.R | 8 +-- R/community.R | 14 ++--- R/conversion.R | 12 ++-- R/decomposition.R | 2 +- R/fit.R | 2 +- R/foreign.R | 14 ++--- R/games.R | 2 +- R/interface.R | 6 +- R/iterators.R | 26 ++++----- R/layout.R | 20 +++---- R/operators.R | 12 ++-- R/par.R | 4 +- R/pp.R | 2 +- R/print.R | 6 +- R/structural-properties.R | 115 ++++++++++++-------------------------- R/topology.R | 2 +- R/utils.R | 4 +- R/uuid.R | 4 +- R/versions.R | 16 +++--- R/weakref.R | 8 +-- 23 files changed, 143 insertions(+), 188 deletions(-) diff --git a/R/attributes.R b/R/attributes.R index 52aac3d2f56..d45ab8853f0 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -328,7 +328,7 @@ graph_attr <- function(graph, name) { check_string(name) - .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ # no _impl + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ name ]] } @@ -388,7 +388,7 @@ set_graph_attr <- function(graph, name, value) { ensure_igraph(graph) - .Call( # no _impl + .Call( Rx_igraph_mybracket3_set, graph, igraph_t_idx_attr, @@ -401,7 +401,7 @@ set_graph_attr <- function(graph, name, value) { #' @export graph.attributes <- function(graph) { ensure_igraph(graph) - .Call( # no _impl + .Call( Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -417,7 +417,7 @@ graph.attributes <- function(graph) { value <- as.list(value) } - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -459,7 +459,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { check_string(name) myattr <- - .Call( # no _impl + .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -609,7 +609,7 @@ i_set_vertex_attr <- function( index <- as_igraph_vs(graph, index) } - vattrs <- .Call( # no _impl + vattrs <- .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -643,7 +643,7 @@ i_set_vertex_attr <- function( } } - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -660,7 +660,7 @@ vertex.attributes <- function(graph, index = V(graph)) { index <- as_igraph_vs(graph, index) } - res <- .Call( # no _impl + res <- .Call( Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -720,7 +720,7 @@ set_value_at <- function(value, idx, length_out) { ) } - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -761,7 +761,7 @@ edge_attr <- function(graph, name, index = E(graph)) { } } else { check_string(name) - myattr <- .Call( # no _impl + myattr <- .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -865,7 +865,7 @@ i_set_edge_attr <- function( index <- as_igraph_es(graph, index) } - eattrs <- .Call( # no _impl + eattrs <- .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -896,7 +896,7 @@ i_set_edge_attr <- function( } } - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -913,7 +913,7 @@ edge.attributes <- function(graph, index = E(graph)) { index <- as_igraph_es(graph, index) } - res <- .Call( # no _impl + res <- .Call( Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -963,7 +963,7 @@ edge.attributes <- function(graph, index = E(graph)) { ) } - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -986,7 +986,7 @@ edge.attributes <- function(graph, index = E(graph)) { #' graph_attr_names(g) graph_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1015,7 +1015,7 @@ graph_attr_names <- function(graph) { vertex_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1043,7 +1043,7 @@ vertex_attr_names <- function(graph) { #' plot(g) edge_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1077,7 +1077,7 @@ delete_graph_attr <- function(graph, name) { cli::cli_abort("No graph attribute {.arg {name}} found.") } - gattr <- .Call( # no _impl + gattr <- .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1085,7 +1085,7 @@ delete_graph_attr <- function(graph, name) { ) gattr[[name]] <- NULL - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -1117,7 +1117,7 @@ delete_vertex_attr <- function(graph, name) { cli::cli_abort("No vertex attribute {.arg {name}} found.") } - vattr <- .Call( # no _impl + vattr <- .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1125,7 +1125,7 @@ delete_vertex_attr <- function(graph, name) { ) vattr[[name]] <- NULL - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -1157,7 +1157,7 @@ delete_edge_attr <- function(graph, name) { cli::cli_abort("No edge attribute {.arg {name}} found.") } - eattr <- .Call( # no _impl + eattr <- .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1165,7 +1165,7 @@ delete_edge_attr <- function(graph, name) { ) eattr[[name]] <- NULL - .Call( # no _impl + .Call( Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, diff --git a/R/bipartite.R b/R/bipartite.R index 3444916b015..c5cabb23870 100644 --- a/R/bipartite.R +++ b/R/bipartite.R @@ -190,7 +190,7 @@ bipartite_projection <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( # no _impl + res <- .Call( Rx_igraph_bipartite_projection, graph, types, diff --git a/R/centrality.R b/R/centrality.R index 419fc348424..a017fa35907 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -992,7 +992,7 @@ arpack <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_arpack, func, extra, options, env, sym) # no _impl + res <- .Call(Rx_igraph_arpack, func, extra, options, env, sym) if (complex) { rew <- arpack.unpack.complex( @@ -1030,7 +1030,7 @@ arpack.unpack.complex <- function(vectors, values, nev) { on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call(Rx_igraph_arpack_unpack_complex, vectors, values, nev) # no _impl + res <- .Call(Rx_igraph_arpack_unpack_complex, vectors, values, nev) res } diff --git a/R/cliques.R b/R/cliques.R index 9bae58314c6..fe3a85f0c35 100644 --- a/R/cliques.R +++ b/R/cliques.R @@ -325,7 +325,7 @@ max_cliques <- function( tmpfile <- FALSE } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_maximal_cliques_file, graph, subset, @@ -350,7 +350,7 @@ max_cliques <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_maximal_cliques, graph, subset_arg, @@ -403,7 +403,7 @@ count_max_cliques <- function(graph, min = NULL, max = NULL, subset = NULL) { on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call(Rx_igraph_maximal_cliques_count, graph, subset, min, max) # maximal_cliques_count_impl() has no subset argument + res <- .Call(Rx_igraph_maximal_cliques_count, graph, subset, min, max) res } @@ -579,7 +579,7 @@ ivs <- function(graph, min = NULL, max = NULL) { } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_independent_vertex_sets, graph, as.numeric(min), diff --git a/R/community.R b/R/community.R index b2c32d495d1..3fdc0df6ec4 100644 --- a/R/community.R +++ b/R/community.R @@ -1315,7 +1315,7 @@ community.to.membership2 <- function(merges, vcount, steps) { mode(vcount) <- "numeric" mode(steps) <- "numeric" on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_community_to_membership2, merges - 1, vcount, steps) # no _impl + res <- .Call(Rx_igraph_community_to_membership2, merges - 1, vcount, steps) res + 1 } @@ -1480,7 +1480,7 @@ cluster_spinglass <- function( on.exit(.Call(Rx_igraph_finalizer)) if (is.null(vertex) || length(vertex) == 0) { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_spinglass_community, graph, weights, @@ -1502,7 +1502,7 @@ cluster_spinglass <- function( } class(res) <- "communities" } else { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_spinglass_my_community, graph, weights, @@ -1858,7 +1858,7 @@ cluster_walktrap <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_walktrap_community, graph, weights, @@ -1986,7 +1986,7 @@ cluster_edge_betweenness <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_community_edge_betweenness, graph, weights, @@ -2078,7 +2078,7 @@ cluster_fast_greedy <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_community_fastgreedy, graph, as.logical(merges), @@ -2100,7 +2100,7 @@ cluster_fast_greedy <- function( igraph.i.levc.arp <- function(externalP, externalE) { f <- function(v) { v <- as.numeric(v) - .Call(R_igraph_levc_arpack_multiplier, externalP, externalE, v) # no _impl + .Call(R_igraph_levc_arpack_multiplier, externalP, externalE, v) } f } diff --git a/R/conversion.R b/R/conversion.R index b7bb5570362..0d73ec08d54 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -656,7 +656,7 @@ as_adj_list <- function( multiple <- if (multiple) 1 else 0 on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_get_adjlist, graph, mode, loops, multiple) # no _impl + res <- .Call(Rx_igraph_get_adjlist, graph, mode, loops, multiple) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) @@ -686,7 +686,7 @@ as_adj_edge_list <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) # no _impl + res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) res <- lapply(res, function(.x) E(graph)[.x + 1]) if (is_named(graph)) { names(res) <- V(graph)$name @@ -1149,7 +1149,7 @@ as_data_frame <- function(x, what = c("edges", "vertices", "both")) { what <- igraph_match_arg(what) if (what %in% c("vertices", "both")) { - ver <- .Call( # no _impl + ver <- .Call( Rx_igraph_mybracket2, x, igraph_t_idx_attr, @@ -1168,7 +1168,7 @@ as_data_frame <- function(x, what = c("edges", "vertices", "both")) { el <- as_edgelist(x) edg <- c( list(from = el[, 1], to = el[, 2]), - .Call(Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) # no _impl + .Call(Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(x)) @@ -1274,7 +1274,7 @@ graph_from_adj_list <- function( as_long_data_frame <- function(graph) { ensure_igraph(graph) - ver <- .Call( # no _impl + ver <- .Call( Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1292,7 +1292,7 @@ as_long_data_frame <- function(graph) { edg <- c( list(from = el[, 1]), list(to = el[, 2]), - .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) # no _impl + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(graph)) diff --git a/R/decomposition.R b/R/decomposition.R index 8004d96ab63..8c8e92b570c 100644 --- a/R/decomposition.R +++ b/R/decomposition.R @@ -133,7 +133,7 @@ is_chordal <- function( fillin <- as.logical(fillin) newgraph <- as.logical(newgraph) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_is_chordal, graph, alpha, diff --git a/R/fit.R b/R/fit.R index ab497276002..e0849b32a4c 100644 --- a/R/fit.R +++ b/R/fit.R @@ -266,7 +266,7 @@ power.law.fit.new <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( # no _impl + res <- .Call( Rx_igraph_power_law_fit_new, data, xmin, diff --git a/R/foreign.R b/R/foreign.R index 119b21e6135..57a927759cd 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -525,7 +525,7 @@ write_graph <- function( read.graph.edgelist <- function(file, n = 0, directed = TRUE) { on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_read_graph_edgelist, file, as.numeric(n), @@ -558,7 +558,7 @@ read.graph.ncol <- function( "auto" = 2L ) on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_read_graph_ncol, file, as.character(predef), @@ -584,7 +584,7 @@ write.graph.ncol <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_write_graph_ncol, graph, file, @@ -606,7 +606,7 @@ read.graph.lgl <- function( "auto" = 2L ) on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_read_graph_lgl, file, as.logical(names), @@ -632,7 +632,7 @@ write.graph.lgl <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_write_graph_lgl, graph, file, @@ -662,7 +662,7 @@ write.graph.pajek <- function(graph, file) { } read.graph.dimacs <- function(file, directed = TRUE) { - res <- .Call(Rx_igraph_read_graph_dimacs, file, as.logical(directed)) # no _impl + res <- .Call(Rx_igraph_read_graph_dimacs, file, as.logical(directed)) if (res[[1]][1] == "max") { graph <- res[[2]] graph <- set_graph_attr(graph, "problem", res[[1]]) @@ -696,7 +696,7 @@ write.graph.dimacs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_write_graph_dimacs, graph, file, diff --git a/R/games.R b/R/games.R index e241d87e87b..dd72d790b03 100644 --- a/R/games.R +++ b/R/games.R @@ -1933,7 +1933,7 @@ traits <- function( #' sample_grg <- function(nodes, radius, torus = FALSE, coords = FALSE) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_grg_game, as.double(nodes), as.double(radius), diff --git a/R/interface.R b/R/interface.R index 4b25dfe9130..f1f1f3b0f5e 100644 --- a/R/interface.R +++ b/R/interface.R @@ -151,7 +151,7 @@ add_edges <- function(graph, edges, ..., attr = list()) { edges.orig <- ecount(graph) on.exit(.Call(Rx_igraph_finalizer)) - graph <- .Call( # no _impl + graph <- .Call( Rx_igraph_add_edges_manual, graph, as_igraph_vs(graph, edges) - 1 @@ -639,7 +639,7 @@ adjacent_vertices <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_adjacent_vertices, graph, vv, mode) # no _impl + res <- .Call(Rx_igraph_adjacent_vertices, graph, vv, mode) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -676,7 +676,7 @@ incident_edges <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_incident_edges, graph, vv, mode) # no _impl + res <- .Call(Rx_igraph_incident_edges, graph, vv, mode) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { diff --git a/R/iterators.R b/R/iterators.R index 76ae4a35e51..cfde92bebd6 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -30,7 +30,7 @@ update_es_ref <- update_vs_ref <- function(graph) { get_es_ref <- get_vs_ref <- function(graph) { if (is_igraph(graph) && !warn_version(graph)) { - .Call(Rx_igraph_copy_env, graph) # no _impl + .Call(Rx_igraph_copy_env, graph) } else { NULL } @@ -84,7 +84,7 @@ get_es_graph_id <- get_vs_graph_id <- function(seq) { #' @export identical_graphs <- function(g1, g2, attrs = TRUE) { stopifnot(is_igraph(g1), is_igraph(g2)) - .Call(Rx_igraph_identical_graphs, g1, g2, as.logical(attrs)) # is_same_graph_impl() has no attrs argument + .Call(Rx_igraph_identical_graphs, g1, g2, as.logical(attrs)) } add_vses_graph_ref <- function(vses, graph) { @@ -362,7 +362,7 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { res <- set_complete_iterator(res) } else if (!is.null(P)) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_es_pairs, graph, as_igraph_vs(graph, P) - 1, @@ -371,7 +371,7 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { 1 } else { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_es_path, graph, as_igraph_vs(graph, path) - 1, @@ -590,7 +590,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { v <- which(v) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( # no _impl + tmp <- .Call( Rx_igraph_vs_nei, graph, x, @@ -621,7 +621,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( # no _impl + tmp <- .Call( Rx_igraph_vs_adj, graph, x, @@ -642,7 +642,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( # no _impl + tmp <- .Call( Rx_igraph_vs_adj, graph, x, @@ -660,7 +660,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( # no _impl + tmp <- .Call( Rx_igraph_vs_adj, graph, x, @@ -983,7 +983,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .inc <- function(v) { ## TRUE iff the edge is incident to at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( # no _impl + tmp <- .Call( Rx_igraph_es_adj, graph, x, @@ -1001,7 +1001,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .from <- function(v) { ## TRUE iff the edge originates from at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( # no _impl + tmp <- .Call( Rx_igraph_es_adj, graph, x, @@ -1016,7 +1016,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .to <- function(v) { ## TRUE iff the edge points to at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( # no _impl + tmp <- .Call( Rx_igraph_es_adj, graph, x, @@ -1061,8 +1061,8 @@ simple_es_index <- function(x, i, na_ok = FALSE) { parent = top, c( attrs, - .igraph.from = list(.Call(Rx_igraph_copy_from, graph)[as.numeric(x)]), # no _impl - .igraph.to = list(.Call(Rx_igraph_copy_to, graph)[as.numeric(x)]), # no _impl + .igraph.from = list(.Call(Rx_igraph_copy_from, graph)[as.numeric(x)]), + .igraph.to = list(.Call(Rx_igraph_copy_to, graph)[as.numeric(x)]), .igraph.graph = list(graph), .env = env, .data = list(attrs) diff --git a/R/layout.R b/R/layout.R index 51f1e19efdd..1f14bbe0fb6 100644 --- a/R/layout.R +++ b/R/layout.R @@ -858,7 +858,7 @@ layout_as_tree <- function( flip.y <- as.logical(flip.y) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( Rx_igraph_layout_reingold_tilford, graph, root, @@ -1575,7 +1575,7 @@ layout_with_fr <- function( on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_layout_fruchterman_reingold, graph, coords, @@ -1589,7 +1589,7 @@ layout_with_fr <- function( grid ) } else { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_layout_fruchterman_reingold_3d, graph, coords, @@ -1767,7 +1767,7 @@ layout_with_graphopt <- function( max.sa.movement <- as.double(max.sa.movement) on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_layout_graphopt, graph, niter, @@ -1930,7 +1930,7 @@ layout_with_kk <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call if (dim == 2) { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_layout_kamada_kawai, graph, coords, @@ -1944,7 +1944,7 @@ layout_with_kk <- function( maxy ) } else { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_layout_kamada_kawai_3d, graph, coords, @@ -2038,7 +2038,7 @@ layout_with_lgl <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_layout_lgl, graph, as.double(maxiter), @@ -2550,7 +2550,7 @@ merge_coords <- function(graphs, layouts, method = "dla") { } on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( Rx_igraph_layout_merge_dla, graphs, layouts @@ -2893,7 +2893,7 @@ layout_with_drl <- function( on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_layout_drl, graph, seed, @@ -2902,7 +2902,7 @@ layout_with_drl <- function( weights ) } else { - res <- .Call( # no _impl + res <- .Call( Rx_igraph_layout_drl_3d, graph, seed, diff --git a/R/operators.R b/R/operators.R index 7ab9b8ee0ce..002e0128a38 100644 --- a/R/operators.R +++ b/R/operators.R @@ -229,7 +229,7 @@ disjoint_union <- function(...) { lapply(graphs, ensure_igraph) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_disjoint_union, graphs) # disjoint_union_many_impl() exists but returns different structure + res <- .Call(Rx_igraph_disjoint_union, graphs) ## Graph attributes graph.attributes(res) <- rename.attr.if.needed("g", graphs) @@ -350,9 +350,9 @@ disjoint_union <- function(...) { on.exit(.Call(Rx_igraph_finalizer)) if (call == "union") { - res <- .Call(Rx_igraph_union, newgraphs, edgemaps) # union_many_impl() has no edgemaps argument + res <- .Call(Rx_igraph_union, newgraphs, edgemaps) } else { - res <- .Call(Rx_igraph_intersection, newgraphs, edgemaps) # intersection_many_impl() has no edgemaps argument + res <- .Call(Rx_igraph_intersection, newgraphs, edgemaps) } maps <- res$edgemaps res <- res$graph @@ -390,9 +390,9 @@ disjoint_union <- function(...) { on.exit(.Call(Rx_igraph_finalizer)) if (call == "union") { - res <- .Call(Rx_igraph_union, graphs, edgemaps) # union_many_impl() has no edgemaps argument + res <- .Call(Rx_igraph_union, graphs, edgemaps) } else { - res <- .Call(Rx_igraph_intersection, graphs, edgemaps) # intersection_many_impl() has no edgemaps argument + res <- .Call(Rx_igraph_intersection, graphs, edgemaps) } maps <- res$edgemaps res <- res$graph @@ -848,7 +848,7 @@ compose <- function(g1, g2, byname = "auto") { length(edge_attr_names(g2)) != 0) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_compose, g1, g2, edgemaps) # compose_impl() has no edgemaps argument + res <- .Call(Rx_igraph_compose, g1, g2, edgemaps) maps <- list(res$edge_map1, res$edge_map2) res <- res$graph diff --git a/R/par.R b/R/par.R index d062374fda8..ac5d3d1c3f8 100644 --- a/R/par.R +++ b/R/par.R @@ -76,7 +76,7 @@ getIgraphOpt <- function(x, default = NULL) { igraph.pars.set.verbose <- function(verbose) { if (is.logical(verbose)) { - .Call(Rx_igraph_set_verbose, verbose) # no _impl + .Call(Rx_igraph_set_verbose, verbose) } else if (is.character(verbose)) { if (!verbose %in% c("tk", "tkconsole")) { cli::cli_abort("Unknown {.arg verbose} value.") @@ -89,7 +89,7 @@ igraph.pars.set.verbose <- function(verbose) { cli::cli_abort("tcltk package not available.") } } - .Call(Rx_igraph_set_verbose, TRUE) # no _impl + .Call(Rx_igraph_set_verbose, TRUE) } else { cli::cli_abort("{.arg verbose} should be a logical or character scalar.") } diff --git a/R/pp.R b/R/pp.R index 666bc777a47..a412f1d434a 100644 --- a/R/pp.R +++ b/R/pp.R @@ -20,5 +20,5 @@ ################################################################### get.all.simple.paths.pp <- function(vect) { - .Call(Rx_igraph_get_all_simple_paths_pp, vect) # no _impl + .Call(Rx_igraph_get_all_simple_paths_pp, vect) } diff --git a/R/print.R b/R/print.R index c676f36e584..243a7d2055d 100644 --- a/R/print.R +++ b/R/print.R @@ -33,7 +33,7 @@ sep = "", gal, " (g/", - .Call(Rx_igraph_get_attr_mode, object, 2L), # no _impl + .Call(Rx_igraph_get_attr_mode, object, 2L), ")" ) } @@ -43,7 +43,7 @@ sep = "", val, " (v/", - .Call(Rx_igraph_get_attr_mode, object, 3L), # no _impl + .Call(Rx_igraph_get_attr_mode, object, 3L), ")" ) } @@ -53,7 +53,7 @@ sep = "", edge_attr_names(object), " (e/", - .Call(Rx_igraph_get_attr_mode, object, 4L), # no _impl + .Call(Rx_igraph_get_attr_mode, object, 4L), ")" ) } diff --git a/R/structural-properties.R b/R/structural-properties.R index ee65ed3dfae..1361a6b464b 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -768,7 +768,7 @@ diameter <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl + .Call( # diameter_impl returns additional path info, not just the diameter value Rx_igraph_diameter, graph, as.logical(directed), @@ -797,7 +797,7 @@ get_diameter <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( # diameter_impl returns different structure (including path info) Rx_igraph_get_diameter, graph, as.logical(directed), @@ -833,7 +833,7 @@ farthest_vertices <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( # no farthest_vertices_impl Rx_igraph_farthest_points, graph, as.logical(directed), @@ -1245,7 +1245,7 @@ distances <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( # distances_impl doesn't support algorithm parameter Rx_igraph_shortest_paths, graph, v - 1, @@ -1329,7 +1329,7 @@ shortest_paths <- function( to <- as_igraph_vs(graph, to) - 1 on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( # get_shortest_paths_impl doesn't support algorithm parameter Rx_igraph_get_shortest_paths, graph, as_igraph_vs(graph, from) - 1, @@ -1522,24 +1522,11 @@ k_shortest_paths <- function( #' subcomponent(g, 1, "out") #' subcomponent(g, 1, "all") subcomponent <- function(graph, v, mode = c("all", "out", "in")) { - ensure_igraph(graph) - mode <- igraph_match_arg(mode) - mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) - - on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl - Rx_igraph_subcomponent, - graph, - as_igraph_vs(graph, v) - 1, - as.numeric(mode) - ) + - 1L - - if (igraph_opt("return.vs.es")) { - res <- create_vs(graph, res) - } - - res + subcomponent_impl( + graph = graph, + vid = v, + mode = mode + ) } #' Subgraph of a graph @@ -1822,7 +1809,7 @@ transitivity <- function( } else if (type == 1) { isolates_num <- as.double(switch(isolates, "nan" = 0, "zero" = 1)) if (is.null(vids)) { - res <- .Call( # transitivity_local_undirected_impl() requires vids, no "all" variant + res <- .Call( # transitivity_local_undirected_impl requires vids, no "all" variant Rx_igraph_transitivity_local_undirected_all, graph, isolates_num @@ -2056,19 +2043,12 @@ ego_size <- function( mode = c("all", "out", "in"), mindist = 0 ) { - ensure_igraph(graph) - mode <- igraph_match_arg(mode) - mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) - mindist <- as.numeric(mindist) - - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # no _impl - Rx_igraph_neighborhood_size, - graph, - as_igraph_vs(graph, nodes) - 1, - as.numeric(order), - as.numeric(mode), - mindist + neighborhood_size_impl( + graph = graph, + vids = nodes, + order = order, + mode = mode, + mindist = mindist ) } @@ -2170,27 +2150,13 @@ ego <- function( mode = c("all", "out", "in"), mindist = 0 ) { - ensure_igraph(graph) - mode <- igraph_match_arg(mode) - mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) - mindist <- as.numeric(mindist) - - on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl - Rx_igraph_neighborhood, - graph, - as_igraph_vs(graph, nodes) - 1, - as.numeric(order), - as.numeric(mode), - mindist + neighborhood_impl( + graph = graph, + vids = nodes, + order = order, + mode = mode, + mindist = mindist ) - res <- lapply(res, function(x) x + 1) - - if (igraph_opt("return.vs.es")) { - res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) - } - - res } #' @export @@ -2205,21 +2171,13 @@ make_ego_graph <- function( mode = c("all", "out", "in"), mindist = 0 ) { - ensure_igraph(graph) - mode <- igraph_match_arg(mode) - mode <- switch(mode, "out" = 1L, "in" = 2L, "all" = 3L) - mindist <- as.numeric(mindist) - - on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl - Rx_igraph_neighborhood_graphs, - graph, - as_igraph_vs(graph, nodes) - 1, - as.numeric(order), - as.integer(mode), - mindist + neighborhood_graphs_impl( + graph = graph, + vids = nodes, + order = order, + mode = mode, + mindist = mindist ) - res } #' @export @@ -2449,15 +2407,12 @@ feedback_vertex_set <- function(graph, weights = NULL, algo = c("exact_ip")) { #' girth(g) #' girth <- function(graph, circle = TRUE) { - ensure_igraph(graph) - - on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_girth, graph, as.logical(circle)) # girth_impl() has no circle argument + res <- girth_impl(graph = graph) if (res$girth == 0) { res$girth <- Inf } - if (igraph_opt("return.vs.es") && circle) { - res$circle <- create_vs(graph, res$circle) + if (!circle) { + res$circle <- NULL } res } @@ -2768,7 +2723,7 @@ bfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( # bfs_simple_impl has different API (no callbacks, etc.) Rx_igraph_bfs, graph, root, @@ -3024,7 +2979,7 @@ dfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no _impl + res <- .Call( # dfs_closure_impl has different API (no callbacks, etc.) Rx_igraph_dfs, graph, root, @@ -3183,7 +3138,7 @@ count_components <- function(graph, mode = c("weak", "strong")) { mode <- switch(mode, "weak" = 1L, "strong" = 2L) on.exit(.Call(Rx_igraph_finalizer)) - .Call(Rx_igraph_no_components, graph, mode) # no _impl + .Call(Rx_igraph_no_components, graph, mode) # connected_components_impl returns membership, not count } #' Count reachable vertices diff --git a/R/topology.R b/R/topology.R index 61488db16e1..c07d59e785e 100644 --- a/R/topology.R +++ b/R/topology.R @@ -220,7 +220,7 @@ graph.subisomorphic.lad <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( # no _impl + res <- .Call( Rx_igraph_subisomorphic_lad, pattern, target, diff --git a/R/utils.R b/R/utils.R index 1dafe63083f..d172590cc0d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -72,7 +72,7 @@ capitalize <- function(x) { } address <- function(x) { - .Call(Rx_igraph_address, x) # no _impl + .Call(Rx_igraph_address, x) } `%+%` <- function(x, y) { @@ -112,5 +112,5 @@ modify_list <- function(x, y) { #' test_error_with_source() #' } test_error_with_source <- function() { - .Call(Rx_igraph_test_error_with_source) # no _impl + .Call(Rx_igraph_test_error_with_source) } diff --git a/R/uuid.R b/R/uuid.R index a6e6385733f..b617afeff4f 100644 --- a/R/uuid.R +++ b/R/uuid.R @@ -1,11 +1,11 @@ generate_uuid <- function(use_time = NA) { - .Call(UUID_gen, as.logical(use_time)) # no _impl + .Call(UUID_gen, as.logical(use_time)) } get_graph_id <- function(graph) { if (!warn_version(graph)) { - .Call(Rx_igraph_get_graph_id, graph) # no _impl + .Call(Rx_igraph_get_graph_id, graph) } else { NA_character_ } diff --git a/R/versions.R b/R/versions.R index 9a5452444b3..40b80ac2a12 100644 --- a/R/versions.R +++ b/R/versions.R @@ -57,7 +57,7 @@ graph_version <- function(graph) { # Don't call is_igraph() here to avoid recursion stopifnot(inherits(graph, "igraph")) - .Call(Rx_igraph_graph_version, graph) # no _impl + .Call(Rx_igraph_graph_version, graph) } #' igraph data structure versions @@ -99,13 +99,13 @@ upgrade_graph <- function(graph) { # g_ver < p_ver if (g_ver == ver_0_4) { - .Call(Rx_igraph_add_env, graph) # no _impl + .Call(Rx_igraph_add_env, graph) } else if (g_ver == ver_0_7_999) { # Not observed in the wild - .Call(Rx_igraph_add_myid_to_env, graph) # no _impl - .Call(Rx_igraph_add_version_to_env, graph) # no _impl + .Call(Rx_igraph_add_myid_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) } else if (g_ver == ver_0_8) { - .Call(Rx_igraph_add_version_to_env, graph) # no _impl + .Call(Rx_igraph_add_version_to_env, graph) graph <- unclass(graph) graph[igraph_t_idx_oi:igraph_t_idx_is] <- list(NULL) class(graph) <- "igraph" @@ -127,10 +127,10 @@ upgrade_graph <- function(graph) { warn_version <- function(graph) { # Calling for side effect: error if Rz_SEXP_to_igraph() fails # Don't call vcount_impl() to avoid recursion - .Call(Rx_igraph_vcount, graph) # vcount_impl() would cause recursion + .Call(Rx_igraph_vcount, graph) # graph_version() calls is_igraph(), but that function must call warn_version() for safety - their_version <- .Call(Rx_igraph_graph_version, graph) # no _impl + their_version <- .Call(Rx_igraph_graph_version, graph) if (pkg_graph_version == their_version) { return(FALSE) @@ -151,7 +151,7 @@ warn_version <- function(graph) { # Users will have to call upgrade_graph(), but this is what the message # is about. if (pkg_graph_version <= ver_1_5_0) { - .Call(Rx_igraph_add_version_to_env, graph) # no _impl + .Call(Rx_igraph_add_version_to_env, graph) } return(TRUE) } diff --git a/R/weakref.R b/R/weakref.R index 5f471bee3a2..45970feeaf1 100644 --- a/R/weakref.R +++ b/R/weakref.R @@ -22,17 +22,17 @@ ## ----------------------------------------------------------------------- make_weak_ref <- function(key, value, finalizer = NULL) { - .Call(Rx_igraph_make_weak_ref, key, value, finalizer) # no _impl + .Call(Rx_igraph_make_weak_ref, key, value, finalizer) } weak_ref_key <- function(ref) { - .Call(Rx_igraph_weak_ref_key, ref) # no _impl + .Call(Rx_igraph_weak_ref_key, ref) } weak_ref_value <- function(ref) { - .Call(Rx_igraph_weak_ref_value, ref) # no _impl + .Call(Rx_igraph_weak_ref_value, ref) } weak_ref_run_finalizer <- function(ref) { - .Call(Rx_igraph_weak_ref_run_finalizer, ref) # no _impl + .Call(Rx_igraph_weak_ref_run_finalizer, ref) } From 5c6041f58044e8d0c3e27e44541a993394633e3a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:19:09 +0000 Subject: [PATCH 05/15] Replace subcomponent, girth, ego_size, ego, make_ego_graph with _impl functions Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/structural-properties.R | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/R/structural-properties.R b/R/structural-properties.R index 1361a6b464b..c7016f3ebaa 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -768,7 +768,7 @@ diameter <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( # diameter_impl returns additional path info, not just the diameter value + .Call( # diameter_impl returns more info (path); uses Dijkstra for weighted Rx_igraph_diameter, graph, as.logical(directed), @@ -797,7 +797,7 @@ get_diameter <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # diameter_impl returns different structure (including path info) + res <- .Call( # diameter_impl returns more info (path) Rx_igraph_get_diameter, graph, as.logical(directed), @@ -833,7 +833,7 @@ farthest_vertices <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # no farthest_vertices_impl + res <- .Call( Rx_igraph_farthest_points, graph, as.logical(directed), @@ -1245,7 +1245,7 @@ distances <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # distances_impl doesn't support algorithm parameter + res <- .Call( Rx_igraph_shortest_paths, graph, v - 1, @@ -1329,7 +1329,7 @@ shortest_paths <- function( to <- as_igraph_vs(graph, to) - 1 on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # get_shortest_paths_impl doesn't support algorithm parameter + res <- .Call( Rx_igraph_get_shortest_paths, graph, as_igraph_vs(graph, from) - 1, @@ -1809,7 +1809,7 @@ transitivity <- function( } else if (type == 1) { isolates_num <- as.double(switch(isolates, "nan" = 0, "zero" = 1)) if (is.null(vids)) { - res <- .Call( # transitivity_local_undirected_impl requires vids, no "all" variant + res <- .Call( Rx_igraph_transitivity_local_undirected_all, graph, isolates_num @@ -2723,7 +2723,7 @@ bfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # bfs_simple_impl has different API (no callbacks, etc.) + res <- .Call( Rx_igraph_bfs, graph, root, @@ -2979,7 +2979,7 @@ dfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # dfs_closure_impl has different API (no callbacks, etc.) + res <- .Call( Rx_igraph_dfs, graph, root, @@ -3138,7 +3138,7 @@ count_components <- function(graph, mode = c("weak", "strong")) { mode <- switch(mode, "weak" = 1L, "strong" = 2L) on.exit(.Call(Rx_igraph_finalizer)) - .Call(Rx_igraph_no_components, graph, mode) # connected_components_impl returns membership, not count + .Call(Rx_igraph_no_components, graph, mode) } #' Count reachable vertices From 483a118a208ffb58800e5d55ff4fd4782141aa74 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:20:38 +0000 Subject: [PATCH 06/15] Add comments to remaining .Call() expressions in structural-properties.R Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/structural-properties.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/structural-properties.R b/R/structural-properties.R index c7016f3ebaa..bf3f6ee2461 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -833,7 +833,7 @@ farthest_vertices <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # no farthest_vertices_impl available Rx_igraph_farthest_points, graph, as.logical(directed), @@ -1245,7 +1245,7 @@ distances <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # distances_impl doesn't support algorithm selection Rx_igraph_shortest_paths, graph, v - 1, @@ -1329,7 +1329,7 @@ shortest_paths <- function( to <- as_igraph_vs(graph, to) - 1 on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # get_shortest_paths_impl doesn't support algorithm selection Rx_igraph_get_shortest_paths, graph, as_igraph_vs(graph, from) - 1, @@ -1809,7 +1809,7 @@ transitivity <- function( } else if (type == 1) { isolates_num <- as.double(switch(isolates, "nan" = 0, "zero" = 1)) if (is.null(vids)) { - res <- .Call( + res <- .Call( # transitivity_local_undirected_impl requires vids Rx_igraph_transitivity_local_undirected_all, graph, isolates_num @@ -2723,7 +2723,7 @@ bfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # bfs_simple_impl has different API (no callbacks) Rx_igraph_bfs, graph, root, @@ -2979,7 +2979,7 @@ dfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # dfs_closure_impl has different API (no callbacks) Rx_igraph_dfs, graph, root, @@ -3138,7 +3138,7 @@ count_components <- function(graph, mode = c("weak", "strong")) { mode <- switch(mode, "weak" = 1L, "strong" = 2L) on.exit(.Call(Rx_igraph_finalizer)) - .Call(Rx_igraph_no_components, graph, mode) + .Call(Rx_igraph_no_components, graph, mode) # connected_components_impl returns membership, not count } #' Count reachable vertices From 08ff3d557f6caa86f3176e6521f82a083c030f20 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:22:10 +0000 Subject: [PATCH 07/15] Add comment explaining efficiency trade-off in girth() using girth_impl() Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/structural-properties.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/structural-properties.R b/R/structural-properties.R index bf3f6ee2461..d35f18ffb6c 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -2407,6 +2407,7 @@ feedback_vertex_set <- function(graph, weights = NULL, algo = c("exact_ip")) { #' girth(g) #' girth <- function(graph, circle = TRUE) { + # girth_impl always computes circle; slightly less efficient when circle=FALSE res <- girth_impl(graph = graph) if (res$girth == 0) { res$girth <- Inf From 86f4d82b5bec3f973a648d506c392a1c22cdfaa5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:40:19 +0000 Subject: [PATCH 08/15] Update BFS/DFS comments to reference bfs_closure_impl/dfs_closure_impl Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/structural-properties.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/structural-properties.R b/R/structural-properties.R index d35f18ffb6c..1a6b6dc68c0 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -2724,7 +2724,7 @@ bfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # bfs_simple_impl has different API (no callbacks) + res <- .Call( # bfs_closure_impl returns only order, not rank/parent/pred/succ/dist Rx_igraph_bfs, graph, root, @@ -2980,7 +2980,7 @@ dfs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # dfs_closure_impl has different API (no callbacks) + res <- .Call( # dfs_closure_impl returns only order/order_out, not parent/dist Rx_igraph_dfs, graph, root, From d2302de2cef0589f9ec62d6d1c83d3b2b6c23fe4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 10:43:28 +0000 Subject: [PATCH 09/15] Add comments to internal .Call() expressions in attributes.R Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/attributes.R | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/R/attributes.R b/R/attributes.R index d45ab8853f0..83adc5b9b4c 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -328,7 +328,7 @@ graph_attr <- function(graph, name) { check_string(name) - .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ # internal, no _impl name ]] } @@ -388,7 +388,7 @@ set_graph_attr <- function(graph, name, value) { ensure_igraph(graph) - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket3_set, graph, igraph_t_idx_attr, @@ -401,7 +401,7 @@ set_graph_attr <- function(graph, name, value) { #' @export graph.attributes <- function(graph) { ensure_igraph(graph) - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -417,7 +417,7 @@ graph.attributes <- function(graph) { value <- as.list(value) } - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -459,7 +459,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { check_string(name) myattr <- - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -609,7 +609,7 @@ i_set_vertex_attr <- function( index <- as_igraph_vs(graph, index) } - vattrs <- .Call( + vattrs <- .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -643,7 +643,7 @@ i_set_vertex_attr <- function( } } - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -660,7 +660,7 @@ vertex.attributes <- function(graph, index = V(graph)) { index <- as_igraph_vs(graph, index) } - res <- .Call( + res <- .Call( # internal, no _impl Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -720,7 +720,7 @@ set_value_at <- function(value, idx, length_out) { ) } - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -761,7 +761,7 @@ edge_attr <- function(graph, name, index = E(graph)) { } } else { check_string(name) - myattr <- .Call( + myattr <- .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -865,7 +865,7 @@ i_set_edge_attr <- function( index <- as_igraph_es(graph, index) } - eattrs <- .Call( + eattrs <- .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -896,7 +896,7 @@ i_set_edge_attr <- function( } } - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -913,7 +913,7 @@ edge.attributes <- function(graph, index = E(graph)) { index <- as_igraph_es(graph, index) } - res <- .Call( + res <- .Call( # internal, no _impl Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, @@ -963,7 +963,7 @@ edge.attributes <- function(graph, index = E(graph)) { ) } - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -986,7 +986,7 @@ edge.attributes <- function(graph, index = E(graph)) { #' graph_attr_names(g) graph_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( + res <- .Call( # internal, no _impl Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1015,7 +1015,7 @@ graph_attr_names <- function(graph) { vertex_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( + res <- .Call( # internal, no _impl Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1043,7 +1043,7 @@ vertex_attr_names <- function(graph) { #' plot(g) edge_attr_names <- function(graph) { ensure_igraph(graph) - res <- .Call( + res <- .Call( # internal, no _impl Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, @@ -1077,7 +1077,7 @@ delete_graph_attr <- function(graph, name) { cli::cli_abort("No graph attribute {.arg {name}} found.") } - gattr <- .Call( + gattr <- .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1085,7 +1085,7 @@ delete_graph_attr <- function(graph, name) { ) gattr[[name]] <- NULL - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -1117,7 +1117,7 @@ delete_vertex_attr <- function(graph, name) { cli::cli_abort("No vertex attribute {.arg {name}} found.") } - vattr <- .Call( + vattr <- .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1125,7 +1125,7 @@ delete_vertex_attr <- function(graph, name) { ) vattr[[name]] <- NULL - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, @@ -1157,7 +1157,7 @@ delete_edge_attr <- function(graph, name) { cli::cli_abort("No edge attribute {.arg {name}} found.") } - eattr <- .Call( + eattr <- .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1165,7 +1165,7 @@ delete_edge_attr <- function(graph, name) { ) eattr[[name]] <- NULL - .Call( + .Call( # internal, no _impl Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, From 05fcfa1f012c390511f65a136ba0e39691a92fb6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:05:50 +0000 Subject: [PATCH 10/15] Add comments and replacements for .Call() in bipartite.R, centrality.R, cliques.R, community.R Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/bipartite.R | 2 +- R/centrality.R | 4 ++-- R/cliques.R | 33 +++++++-------------------------- R/community.R | 24 ++++++++++++------------ 4 files changed, 22 insertions(+), 41 deletions(-) diff --git a/R/bipartite.R b/R/bipartite.R index c5cabb23870..1fc4a823c2a 100644 --- a/R/bipartite.R +++ b/R/bipartite.R @@ -190,7 +190,7 @@ bipartite_projection <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( + res <- .Call( # bipartite_projection_impl lacks which/multiplicity parameters Rx_igraph_bipartite_projection, graph, types, diff --git a/R/centrality.R b/R/centrality.R index a017fa35907..b1d03391ec2 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -992,7 +992,7 @@ arpack <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_arpack, func, extra, options, env, sym) + res <- .Call(Rx_igraph_arpack, func, extra, options, env, sym) # ARPACK, no _impl if (complex) { rew <- arpack.unpack.complex( @@ -1030,7 +1030,7 @@ arpack.unpack.complex <- function(vectors, values, nev) { on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call(Rx_igraph_arpack_unpack_complex, vectors, values, nev) + res <- .Call(Rx_igraph_arpack_unpack_complex, vectors, values, nev) # ARPACK, no _impl res } diff --git a/R/cliques.R b/R/cliques.R index fe3a85f0c35..d2cb69f02be 100644 --- a/R/cliques.R +++ b/R/cliques.R @@ -325,7 +325,7 @@ max_cliques <- function( tmpfile <- FALSE } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # maximal_cliques_file_impl doesn't support subset Rx_igraph_maximal_cliques_file, graph, subset, @@ -350,7 +350,7 @@ max_cliques <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # maximal_cliques_impl doesn't support subset Rx_igraph_maximal_cliques, graph, subset_arg, @@ -403,7 +403,7 @@ count_max_cliques <- function(graph, min = NULL, max = NULL, subset = NULL) { on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call(Rx_igraph_maximal_cliques_count, graph, subset, min, max) + res <- .Call(Rx_igraph_maximal_cliques_count, graph, subset, min, max) # _impl lacks subset res } @@ -568,30 +568,11 @@ weighted_clique_num <- function(graph, vertex.weights = NULL) { #' #' length(max_ivs(g)) ivs <- function(graph, min = NULL, max = NULL) { - ensure_igraph(graph) - - if (is.null(min)) { - min <- 0 - } - - if (is.null(max)) { - max <- 0 - } - - on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( - Rx_igraph_independent_vertex_sets, - graph, - as.numeric(min), - as.numeric(max) + independent_vertex_sets_impl( + graph = graph, + min_size = min %||% 0, + max_size = max %||% 0 ) - res <- lapply(res, `+`, 1) - - if (igraph_opt("return.vs.es")) { - res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) - } - - res } #' @rdname ivs diff --git a/R/community.R b/R/community.R index 3fdc0df6ec4..8307adbc709 100644 --- a/R/community.R +++ b/R/community.R @@ -1311,12 +1311,12 @@ show_trace <- function(communities) { ##################################################################### community.to.membership2 <- function(merges, vcount, steps) { - mode(merges) <- "numeric" - mode(vcount) <- "numeric" - mode(steps) <- "numeric" - on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_community_to_membership2, merges - 1, vcount, steps) - res + 1 + res <- community_to_membership_impl( + merges = merges - 1, + nodes = vcount, + steps = steps + ) + res$membership + 1 } ##################################################################### @@ -1480,7 +1480,7 @@ cluster_spinglass <- function( on.exit(.Call(Rx_igraph_finalizer)) if (is.null(vertex) || length(vertex) == 0) { - res <- .Call( + res <- .Call( # community_spinglass_impl uses different parameter names Rx_igraph_spinglass_community, graph, weights, @@ -1502,7 +1502,7 @@ cluster_spinglass <- function( } class(res) <- "communities" } else { - res <- .Call( + res <- .Call( # community_spinglass_single_impl has different API Rx_igraph_spinglass_my_community, graph, weights, @@ -1858,7 +1858,7 @@ cluster_walktrap <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # community_walktrap_impl lacks output control parameters Rx_igraph_walktrap_community, graph, weights, @@ -1986,7 +1986,7 @@ cluster_edge_betweenness <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # community_edge_betweenness_impl lacks output control parameters Rx_igraph_community_edge_betweenness, graph, weights, @@ -2078,7 +2078,7 @@ cluster_fast_greedy <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # community_fastgreedy_impl lacks output control parameters Rx_igraph_community_fastgreedy, graph, as.logical(merges), @@ -2100,7 +2100,7 @@ cluster_fast_greedy <- function( igraph.i.levc.arp <- function(externalP, externalE) { f <- function(v) { v <- as.numeric(v) - .Call(R_igraph_levc_arpack_multiplier, externalP, externalE, v) + .Call(R_igraph_levc_arpack_multiplier, externalP, externalE, v) # internal ARPACK, no _impl } f } From 085591dcd08486e6dea01b7335e7db480ab39b19 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:27:28 +0000 Subject: [PATCH 11/15] Add comments to all remaining .Call() expressions across R files Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/conversion.R | 12 ++++++------ R/decomposition.R | 2 +- R/fit.R | 2 +- R/foreign.R | 14 +++++++------- R/games.R | 2 +- R/interface.R | 6 +++--- R/iterators.R | 26 +++++++++++++------------- R/layout.R | 20 ++++++++++---------- R/operators.R | 12 ++++++------ R/par.R | 4 ++-- R/pp.R | 2 +- R/print.R | 6 +++--- R/topology.R | 2 +- R/utils.R | 2 +- R/uuid.R | 2 +- R/versions.R | 14 +++++++------- R/weakref.R | 8 ++++---- 17 files changed, 68 insertions(+), 68 deletions(-) diff --git a/R/conversion.R b/R/conversion.R index 0d73ec08d54..d6cb0331fc9 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -656,7 +656,7 @@ as_adj_list <- function( multiple <- if (multiple) 1 else 0 on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_get_adjlist, graph, mode, loops, multiple) + res <- .Call(Rx_igraph_get_adjlist, graph, mode, loops, multiple) # no _impl res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) @@ -686,7 +686,7 @@ as_adj_edge_list <- function( } on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) + res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) # no _impl res <- lapply(res, function(.x) E(graph)[.x + 1]) if (is_named(graph)) { names(res) <- V(graph)$name @@ -1149,7 +1149,7 @@ as_data_frame <- function(x, what = c("edges", "vertices", "both")) { what <- igraph_match_arg(what) if (what %in% c("vertices", "both")) { - ver <- .Call( + ver <- .Call( # internal, no _impl Rx_igraph_mybracket2, x, igraph_t_idx_attr, @@ -1168,7 +1168,7 @@ as_data_frame <- function(x, what = c("edges", "vertices", "both")) { el <- as_edgelist(x) edg <- c( list(from = el[, 1], to = el[, 2]), - .Call(Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) + .Call(Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) # internal, no _impl ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(x)) @@ -1274,7 +1274,7 @@ graph_from_adj_list <- function( as_long_data_frame <- function(graph) { ensure_igraph(graph) - ver <- .Call( + ver <- .Call( # internal, no _impl Rx_igraph_mybracket2, graph, igraph_t_idx_attr, @@ -1292,7 +1292,7 @@ as_long_data_frame <- function(graph) { edg <- c( list(from = el[, 1]), list(to = el[, 2]), - .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) # internal, no _impl ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(graph)) diff --git a/R/decomposition.R b/R/decomposition.R index 8c8e92b570c..ccbd5453a73 100644 --- a/R/decomposition.R +++ b/R/decomposition.R @@ -133,7 +133,7 @@ is_chordal <- function( fillin <- as.logical(fillin) newgraph <- as.logical(newgraph) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # is_chordal_impl lacks fillin/newgraph parameters Rx_igraph_is_chordal, graph, alpha, diff --git a/R/fit.R b/R/fit.R index e0849b32a4c..3a9f10f3d61 100644 --- a/R/fit.R +++ b/R/fit.R @@ -266,7 +266,7 @@ power.law.fit.new <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( + res <- .Call( # power_law_fit_impl lacks p.value/p.precision parameters Rx_igraph_power_law_fit_new, data, xmin, diff --git a/R/foreign.R b/R/foreign.R index 57a927759cd..cdf0ff290a0 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -525,7 +525,7 @@ write_graph <- function( read.graph.edgelist <- function(file, n = 0, directed = TRUE) { on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # read_graph_edgelist_impl has different file handling Rx_igraph_read_graph_edgelist, file, as.numeric(n), @@ -558,7 +558,7 @@ read.graph.ncol <- function( "auto" = 2L ) on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # read_graph_ncol_impl has different file handling Rx_igraph_read_graph_ncol, file, as.character(predef), @@ -584,7 +584,7 @@ write.graph.ncol <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # write_graph_ncol_impl has different file handling Rx_igraph_write_graph_ncol, graph, file, @@ -606,7 +606,7 @@ read.graph.lgl <- function( "auto" = 2L ) on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # read_graph_lgl_impl has different file handling Rx_igraph_read_graph_lgl, file, as.logical(names), @@ -632,7 +632,7 @@ write.graph.lgl <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # write_graph_lgl_impl has different file handling Rx_igraph_write_graph_lgl, graph, file, @@ -662,7 +662,7 @@ write.graph.pajek <- function(graph, file) { } read.graph.dimacs <- function(file, directed = TRUE) { - res <- .Call(Rx_igraph_read_graph_dimacs, file, as.logical(directed)) + res <- .Call(Rx_igraph_read_graph_dimacs, # read_graph_dimacs_flow_impl has different API file, as.logical(directed)) if (res[[1]][1] == "max") { graph <- res[[2]] graph <- set_graph_attr(graph, "problem", res[[1]]) @@ -696,7 +696,7 @@ write.graph.dimacs <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # write_graph_dimacs_flow_impl has different API Rx_igraph_write_graph_dimacs, graph, file, diff --git a/R/games.R b/R/games.R index dd72d790b03..e0289a31185 100644 --- a/R/games.R +++ b/R/games.R @@ -1933,7 +1933,7 @@ traits <- function( #' sample_grg <- function(nodes, radius, torus = FALSE, coords = FALSE) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # grg_game_impl lacks torus/coords parameters Rx_igraph_grg_game, as.double(nodes), as.double(radius), diff --git a/R/interface.R b/R/interface.R index f1f1f3b0f5e..645228a92e7 100644 --- a/R/interface.R +++ b/R/interface.R @@ -151,7 +151,7 @@ add_edges <- function(graph, edges, ..., attr = list()) { edges.orig <- ecount(graph) on.exit(.Call(Rx_igraph_finalizer)) - graph <- .Call( + graph <- .Call( # add_edges_impl has different API Rx_igraph_add_edges_manual, graph, as_igraph_vs(graph, edges) - 1 @@ -639,7 +639,7 @@ adjacent_vertices <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_adjacent_vertices, graph, vv, mode) + res <- .Call(Rx_igraph_adjacent_vertices, # neighbors_impl takes single vertex graph, vv, mode) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -676,7 +676,7 @@ incident_edges <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_incident_edges, graph, vv, mode) + res <- .Call(Rx_igraph_incident_edges, # incident_impl takes single vertex graph, vv, mode) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { diff --git a/R/iterators.R b/R/iterators.R index cfde92bebd6..81022d2e9ce 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -30,7 +30,7 @@ update_es_ref <- update_vs_ref <- function(graph) { get_es_ref <- get_vs_ref <- function(graph) { if (is_igraph(graph) && !warn_version(graph)) { - .Call(Rx_igraph_copy_env, graph) + .Call(Rx_igraph_copy_env, graph) # internal, no _impl } else { NULL } @@ -84,7 +84,7 @@ get_es_graph_id <- get_vs_graph_id <- function(seq) { #' @export identical_graphs <- function(g1, g2, attrs = TRUE) { stopifnot(is_igraph(g1), is_igraph(g2)) - .Call(Rx_igraph_identical_graphs, g1, g2, as.logical(attrs)) + .Call(Rx_igraph_identical_graphs, # is_same_graph_impl has different semantics g1, g2, as.logical(attrs)) } add_vses_graph_ref <- function(vses, graph) { @@ -362,7 +362,7 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { res <- set_complete_iterator(res) } else if (!is.null(P)) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # internal, no _impl Rx_igraph_es_pairs, graph, as_igraph_vs(graph, P) - 1, @@ -371,7 +371,7 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { 1 } else { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # internal, no _impl Rx_igraph_es_path, graph, as_igraph_vs(graph, path) - 1, @@ -590,7 +590,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { v <- which(v) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # internal, no _impl Rx_igraph_vs_nei, graph, x, @@ -621,7 +621,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # internal, no _impl Rx_igraph_vs_adj, graph, x, @@ -642,7 +642,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # internal, no _impl Rx_igraph_vs_adj, graph, x, @@ -660,7 +660,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { e <- which(e) } on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # internal, no _impl Rx_igraph_vs_adj, graph, x, @@ -983,7 +983,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .inc <- function(v) { ## TRUE iff the edge is incident to at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # internal, no _impl Rx_igraph_es_adj, graph, x, @@ -1001,7 +1001,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .from <- function(v) { ## TRUE iff the edge originates from at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # internal, no _impl Rx_igraph_es_adj, graph, x, @@ -1016,7 +1016,7 @@ simple_es_index <- function(x, i, na_ok = FALSE) { .to <- function(v) { ## TRUE iff the edge points to at least one vertex in v on.exit(.Call(Rx_igraph_finalizer)) - tmp <- .Call( + tmp <- .Call( # internal, no _impl Rx_igraph_es_adj, graph, x, @@ -1061,8 +1061,8 @@ simple_es_index <- function(x, i, na_ok = FALSE) { parent = top, c( attrs, - .igraph.from = list(.Call(Rx_igraph_copy_from, graph)[as.numeric(x)]), - .igraph.to = list(.Call(Rx_igraph_copy_to, graph)[as.numeric(x)]), + .igraph.from = list(.Call(Rx_igraph_copy_from, graph) # internal, no _impl[as.numeric(x)]), + .igraph.to = list(.Call(Rx_igraph_copy_to, graph) # internal, no _impl[as.numeric(x)]), .igraph.graph = list(graph), .env = env, .data = list(attrs) diff --git a/R/layout.R b/R/layout.R index 1f14bbe0fb6..4848c4f475c 100644 --- a/R/layout.R +++ b/R/layout.R @@ -858,7 +858,7 @@ layout_as_tree <- function( flip.y <- as.logical(flip.y) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( + res <- .Call( # layout_reingold_tilford_impl has different API Rx_igraph_layout_reingold_tilford, graph, root, @@ -1575,7 +1575,7 @@ layout_with_fr <- function( on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( + res <- .Call( # layout_fruchterman_reingold_impl has different API Rx_igraph_layout_fruchterman_reingold, graph, coords, @@ -1589,7 +1589,7 @@ layout_with_fr <- function( grid ) } else { - res <- .Call( + res <- .Call( # layout_fruchterman_reingold_3d_impl has different API Rx_igraph_layout_fruchterman_reingold_3d, graph, coords, @@ -1767,7 +1767,7 @@ layout_with_graphopt <- function( max.sa.movement <- as.double(max.sa.movement) on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # layout_graphopt_impl has different API Rx_igraph_layout_graphopt, graph, niter, @@ -1930,7 +1930,7 @@ layout_with_kk <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call if (dim == 2) { - res <- .Call( + res <- .Call( # layout_kamada_kawai_impl has different API Rx_igraph_layout_kamada_kawai, graph, coords, @@ -1944,7 +1944,7 @@ layout_with_kk <- function( maxy ) } else { - res <- .Call( + res <- .Call( # layout_kamada_kawai_3d_impl has different API Rx_igraph_layout_kamada_kawai_3d, graph, coords, @@ -2038,7 +2038,7 @@ layout_with_lgl <- function( } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # layout_lgl_impl has different API Rx_igraph_layout_lgl, graph, as.double(maxiter), @@ -2550,7 +2550,7 @@ merge_coords <- function(graphs, layouts, method = "dla") { } on.exit(.Call(Rx_igraph_finalizer)) - .Call( + .Call( # layout_merge_dla_impl has different API Rx_igraph_layout_merge_dla, graphs, layouts @@ -2893,7 +2893,7 @@ layout_with_drl <- function( on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( + res <- .Call( # layout_drl_impl has different API Rx_igraph_layout_drl, graph, seed, @@ -2902,7 +2902,7 @@ layout_with_drl <- function( weights ) } else { - res <- .Call( + res <- .Call( # layout_drl_3d_impl has different API Rx_igraph_layout_drl_3d, graph, seed, diff --git a/R/operators.R b/R/operators.R index 002e0128a38..9e4105a4105 100644 --- a/R/operators.R +++ b/R/operators.R @@ -229,7 +229,7 @@ disjoint_union <- function(...) { lapply(graphs, ensure_igraph) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_disjoint_union, graphs) + res <- .Call(Rx_igraph_disjoint_union, graphs) # disjoint_union_many_impl does not merge attributes ## Graph attributes graph.attributes(res) <- rename.attr.if.needed("g", graphs) @@ -350,9 +350,9 @@ disjoint_union <- function(...) { on.exit(.Call(Rx_igraph_finalizer)) if (call == "union") { - res <- .Call(Rx_igraph_union, newgraphs, edgemaps) + res <- .Call(Rx_igraph_union, newgraphs, edgemaps) # union_many_impl does not return edgemaps } else { - res <- .Call(Rx_igraph_intersection, newgraphs, edgemaps) + res <- .Call(Rx_igraph_intersection, newgraphs, edgemaps) # intersection_many_impl does not return edgemaps } maps <- res$edgemaps res <- res$graph @@ -390,9 +390,9 @@ disjoint_union <- function(...) { on.exit(.Call(Rx_igraph_finalizer)) if (call == "union") { - res <- .Call(Rx_igraph_union, graphs, edgemaps) + res <- .Call(Rx_igraph_union, graphs, edgemaps) # union_many_impl does not return edgemaps } else { - res <- .Call(Rx_igraph_intersection, graphs, edgemaps) + res <- .Call(Rx_igraph_intersection, graphs, edgemaps) # intersection_many_impl does not return edgemaps } maps <- res$edgemaps res <- res$graph @@ -848,7 +848,7 @@ compose <- function(g1, g2, byname = "auto") { length(edge_attr_names(g2)) != 0) on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_compose, g1, g2, edgemaps) + res <- .Call(Rx_igraph_compose, g1, g2, edgemaps) # compose_impl does not return edgemaps maps <- list(res$edge_map1, res$edge_map2) res <- res$graph diff --git a/R/par.R b/R/par.R index ac5d3d1c3f8..f9b46ee9b35 100644 --- a/R/par.R +++ b/R/par.R @@ -76,7 +76,7 @@ getIgraphOpt <- function(x, default = NULL) { igraph.pars.set.verbose <- function(verbose) { if (is.logical(verbose)) { - .Call(Rx_igraph_set_verbose, verbose) + .Call(Rx_igraph_set_verbose, verbose) # internal, no _impl } else if (is.character(verbose)) { if (!verbose %in% c("tk", "tkconsole")) { cli::cli_abort("Unknown {.arg verbose} value.") @@ -89,7 +89,7 @@ igraph.pars.set.verbose <- function(verbose) { cli::cli_abort("tcltk package not available.") } } - .Call(Rx_igraph_set_verbose, TRUE) + .Call(Rx_igraph_set_verbose, TRUE) # internal, no _impl } else { cli::cli_abort("{.arg verbose} should be a logical or character scalar.") } diff --git a/R/pp.R b/R/pp.R index a412f1d434a..081485d83e6 100644 --- a/R/pp.R +++ b/R/pp.R @@ -20,5 +20,5 @@ ################################################################### get.all.simple.paths.pp <- function(vect) { - .Call(Rx_igraph_get_all_simple_paths_pp, vect) + .Call(Rx_igraph_get_all_simple_paths_pp, vect) # internal, no _impl } diff --git a/R/print.R b/R/print.R index 243a7d2055d..932ccf47b13 100644 --- a/R/print.R +++ b/R/print.R @@ -33,7 +33,7 @@ sep = "", gal, " (g/", - .Call(Rx_igraph_get_attr_mode, object, 2L), + .Call(Rx_igraph_get_attr_mode, object, 2L) # internal, no _impl, ")" ) } @@ -43,7 +43,7 @@ sep = "", val, " (v/", - .Call(Rx_igraph_get_attr_mode, object, 3L), + .Call(Rx_igraph_get_attr_mode, object, 3L) # internal, no _impl, ")" ) } @@ -53,7 +53,7 @@ sep = "", edge_attr_names(object), " (e/", - .Call(Rx_igraph_get_attr_mode, object, 4L), + .Call(Rx_igraph_get_attr_mode, object, 4L) # internal, no _impl, ")" ) } diff --git a/R/topology.R b/R/topology.R index c07d59e785e..1ef9f628b06 100644 --- a/R/topology.R +++ b/R/topology.R @@ -220,7 +220,7 @@ graph.subisomorphic.lad <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( + res <- .Call( # subisomorphic_lad_impl has different API Rx_igraph_subisomorphic_lad, pattern, target, diff --git a/R/utils.R b/R/utils.R index d172590cc0d..83e7778acbc 100644 --- a/R/utils.R +++ b/R/utils.R @@ -72,7 +72,7 @@ capitalize <- function(x) { } address <- function(x) { - .Call(Rx_igraph_address, x) + .Call(Rx_igraph_address, x) # internal, no _impl } `%+%` <- function(x, y) { diff --git a/R/uuid.R b/R/uuid.R index b617afeff4f..094427b2f42 100644 --- a/R/uuid.R +++ b/R/uuid.R @@ -5,7 +5,7 @@ generate_uuid <- function(use_time = NA) { get_graph_id <- function(graph) { if (!warn_version(graph)) { - .Call(Rx_igraph_get_graph_id, graph) + .Call(Rx_igraph_get_graph_id, graph) # internal, no _impl } else { NA_character_ } diff --git a/R/versions.R b/R/versions.R index 40b80ac2a12..4e515a2266f 100644 --- a/R/versions.R +++ b/R/versions.R @@ -57,7 +57,7 @@ graph_version <- function(graph) { # Don't call is_igraph() here to avoid recursion stopifnot(inherits(graph, "igraph")) - .Call(Rx_igraph_graph_version, graph) + .Call(Rx_igraph_graph_version, graph) # internal, no _impl } #' igraph data structure versions @@ -99,13 +99,13 @@ upgrade_graph <- function(graph) { # g_ver < p_ver if (g_ver == ver_0_4) { - .Call(Rx_igraph_add_env, graph) + .Call(Rx_igraph_add_env, graph) # internal, no _impl } else if (g_ver == ver_0_7_999) { # Not observed in the wild - .Call(Rx_igraph_add_myid_to_env, graph) - .Call(Rx_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_myid_to_env, graph) # internal, no _impl + .Call(Rx_igraph_add_version_to_env, graph) # internal, no _impl } else if (g_ver == ver_0_8) { - .Call(Rx_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) # internal, no _impl graph <- unclass(graph) graph[igraph_t_idx_oi:igraph_t_idx_is] <- list(NULL) class(graph) <- "igraph" @@ -130,7 +130,7 @@ warn_version <- function(graph) { .Call(Rx_igraph_vcount, graph) # graph_version() calls is_igraph(), but that function must call warn_version() for safety - their_version <- .Call(Rx_igraph_graph_version, graph) + their_version <- .Call(Rx_igraph_graph_version, graph) # internal, no _impl if (pkg_graph_version == their_version) { return(FALSE) @@ -151,7 +151,7 @@ warn_version <- function(graph) { # Users will have to call upgrade_graph(), but this is what the message # is about. if (pkg_graph_version <= ver_1_5_0) { - .Call(Rx_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) # internal, no _impl } return(TRUE) } diff --git a/R/weakref.R b/R/weakref.R index 45970feeaf1..2e1af8edfc5 100644 --- a/R/weakref.R +++ b/R/weakref.R @@ -22,17 +22,17 @@ ## ----------------------------------------------------------------------- make_weak_ref <- function(key, value, finalizer = NULL) { - .Call(Rx_igraph_make_weak_ref, key, value, finalizer) + .Call(Rx_igraph_make_weak_ref, key, value, finalizer) # internal, no _impl } weak_ref_key <- function(ref) { - .Call(Rx_igraph_weak_ref_key, ref) + .Call(Rx_igraph_weak_ref_key, ref) # internal, no _impl } weak_ref_value <- function(ref) { - .Call(Rx_igraph_weak_ref_value, ref) + .Call(Rx_igraph_weak_ref_value, ref) # internal, no _impl } weak_ref_run_finalizer <- function(ref) { - .Call(Rx_igraph_weak_ref_run_finalizer, ref) + .Call(Rx_igraph_weak_ref_run_finalizer, ref) # internal, no _impl } From d7c4ce7343ceaa3bdc4eb3850109e769ef8aa058 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:48:33 +0000 Subject: [PATCH 12/15] Replace .Call() with _impl functions in layout, interface, foreign files; fix API adaptations Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/foreign.R | 97 +++++++++------------- R/interface.R | 22 +++-- R/iterators.R | 14 +++- R/layout.R | 222 +++++++++++++++++++++++++------------------------- R/print.R | 6 +- R/topology.R | 2 +- 6 files changed, 179 insertions(+), 184 deletions(-) diff --git a/R/foreign.R b/R/foreign.R index cdf0ff290a0..7b58975a3d5 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -524,12 +524,10 @@ write_graph <- function( ################################################################ read.graph.edgelist <- function(file, n = 0, directed = TRUE) { - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # read_graph_edgelist_impl has different file handling - Rx_igraph_read_graph_edgelist, - file, - as.numeric(n), - as.logical(directed) + read_graph_edgelist_impl( + instream = file, + n = n, + directed = directed ) } @@ -551,20 +549,13 @@ read.graph.ncol <- function( weights = c("auto", "yes", "no"), directed = FALSE ) { - weights <- switch( - igraph_match_arg(weights), - "no" = 0L, - "yes" = 1L, - "auto" = 2L - ) - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # read_graph_ncol_impl has different file handling - Rx_igraph_read_graph_ncol, - file, - as.character(predef), - as.logical(names), - weights, - as.logical(directed) + weights <- igraph_match_arg(weights) + read_graph_ncol_impl( + instream = file, + predefnames = predef, + names = names, + weights = switch(weights, "no" = FALSE, "yes" = TRUE, "auto" = NA), + directed = directed ) } @@ -583,13 +574,11 @@ write.graph.ncol <- function( weights <- NULL } - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # write_graph_ncol_impl has different file handling - Rx_igraph_write_graph_ncol, - graph, - file, - names, - weights + write_graph_ncol_impl( + graph = graph, + outstream = file, + names = names, + weights = weights ) } @@ -599,19 +588,12 @@ read.graph.lgl <- function( weights = c("auto", "yes", "no"), directed = FALSE ) { - weights <- switch( - igraph_match_arg(weights), - "no" = 0L, - "yes" = 1L, - "auto" = 2L - ) - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # read_graph_lgl_impl has different file handling - Rx_igraph_read_graph_lgl, - file, - as.logical(names), - weights, - as.logical(directed) + weights <- igraph_match_arg(weights) + read_graph_lgl_impl( + instream = file, + names = names, + weights = weights, + directed = directed ) } @@ -631,14 +613,12 @@ write.graph.lgl <- function( weights <- NULL } - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # write_graph_lgl_impl has different file handling - Rx_igraph_write_graph_lgl, - graph, - file, - names, - weights, - as.logical(isolates) + write_graph_lgl_impl( + graph = graph, + outstream = file, + names = names, + weights = weights, + isolates = isolates ) } @@ -662,7 +642,12 @@ write.graph.pajek <- function(graph, file) { } read.graph.dimacs <- function(file, directed = TRUE) { - res <- .Call(Rx_igraph_read_graph_dimacs, # read_graph_dimacs_flow_impl has different API file, as.logical(directed)) + on.exit(.Call(Rx_igraph_finalizer)) + res <- .Call( # read_graph_dimacs_flow_impl returns different structure + Rx_igraph_read_graph_dimacs, + file, + as.logical(directed) + ) if (res[[1]][1] == "max") { graph <- res[[2]] graph <- set_graph_attr(graph, "problem", res[[1]]) @@ -695,14 +680,12 @@ write.graph.dimacs <- function( capacity <- E(graph)$capacity } - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # write_graph_dimacs_flow_impl has different API - Rx_igraph_write_graph_dimacs, - graph, - file, - as.numeric(source), - as.numeric(target), - as.numeric(capacity) + write_graph_dimacs_flow_impl( + graph = graph, + outstream = file, + source = source, + target = target, + capacity = capacity ) } diff --git a/R/interface.R b/R/interface.R index 645228a92e7..555e746b629 100644 --- a/R/interface.R +++ b/R/interface.R @@ -150,11 +150,9 @@ add_edges <- function(graph, edges, ..., attr = list()) { } edges.orig <- ecount(graph) - on.exit(.Call(Rx_igraph_finalizer)) - graph <- .Call( # add_edges_impl has different API - Rx_igraph_add_edges_manual, - graph, - as_igraph_vs(graph, edges) - 1 + graph <- add_edges_impl( + graph = graph, + edges = edges ) edges.new <- ecount(graph) @@ -639,7 +637,12 @@ adjacent_vertices <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_adjacent_vertices, # neighbors_impl takes single vertex graph, vv, mode) + res <- .Call( # neighbors_impl takes single vertex + Rx_igraph_adjacent_vertices, + graph, + vv, + mode + ) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -676,7 +679,12 @@ incident_edges <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call(Rx_igraph_incident_edges, # incident_impl takes single vertex graph, vv, mode) + res <- .Call( # incident_impl takes single vertex + Rx_igraph_incident_edges, + graph, + vv, + mode + ) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { diff --git a/R/iterators.R b/R/iterators.R index 81022d2e9ce..626424377f3 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -84,7 +84,13 @@ get_es_graph_id <- get_vs_graph_id <- function(seq) { #' @export identical_graphs <- function(g1, g2, attrs = TRUE) { stopifnot(is_igraph(g1), is_igraph(g2)) - .Call(Rx_igraph_identical_graphs, # is_same_graph_impl has different semantics g1, g2, as.logical(attrs)) + on.exit(.Call(Rx_igraph_finalizer)) + .Call( # is_same_graph_impl lacks attrs parameter + Rx_igraph_identical_graphs, + g1, + g2, + as.logical(attrs) + ) } add_vses_graph_ref <- function(vses, graph) { @@ -1057,12 +1063,14 @@ simple_es_index <- function(x, i, na_ok = FALSE) { )) # Data objects (visible by default) + from_copy <- .Call(Rx_igraph_copy_from, graph) # internal, no _impl + to_copy <- .Call(Rx_igraph_copy_to, graph) # internal, no _impl bottom <- rlang::new_environment( parent = top, c( attrs, - .igraph.from = list(.Call(Rx_igraph_copy_from, graph) # internal, no _impl[as.numeric(x)]), - .igraph.to = list(.Call(Rx_igraph_copy_to, graph) # internal, no _impl[as.numeric(x)]), + .igraph.from = list(from_copy[as.numeric(x)]), + .igraph.to = list(to_copy[as.numeric(x)]), .igraph.graph = list(graph), .env = env, .data = list(attrs) diff --git a/R/layout.R b/R/layout.R index 4848c4f475c..42b31909384 100644 --- a/R/layout.R +++ b/R/layout.R @@ -848,24 +848,24 @@ layout_as_tree <- function( root <- as_igraph_vs(graph, root) - 1 circular <- as.logical(circular) rootlevel <- as.double(rootlevel) - mode <- switch( - igraph_match_arg(mode), - "out" = 1, - "in" = 2, - "all" = 3, - "total" = 3 - ) + mode <- igraph_match_arg(mode) flip.y <- as.logical(flip.y) - on.exit(.Call(Rx_igraph_finalizer)) - res <- .Call( # layout_reingold_tilford_impl has different API - Rx_igraph_layout_reingold_tilford, - graph, - root, - mode, - rootlevel, - circular - ) + if (circular) { + res <- layout_reingold_tilford_circular_impl( + graph = graph, + mode = mode, + roots = root, + rootlevel = rootlevel + ) + } else { + res <- layout_reingold_tilford_impl( + graph = graph, + mode = mode, + roots = root, + rootlevel = rootlevel + ) + } if (flip.y && vcount(graph) > 0) { res[, 2] <- max(res[, 2]) - res[, 2] } @@ -1532,7 +1532,6 @@ layout_with_fr <- function( start.temp <- as.numeric(start.temp) grid <- igraph_match_arg(grid) - grid <- switch(grid, "grid" = 0L, "nogrid" = 1L, "auto" = 2L) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight @@ -1573,35 +1572,34 @@ layout_with_fr <- function( lifecycle::deprecate_stop("0.8.0", "layout_with_fr(repulserad = )") } - on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( # layout_fruchterman_reingold_impl has different API - Rx_igraph_layout_fruchterman_reingold, - graph, - coords, - niter, - start.temp, - weights, - minx, - maxx, - miny, - maxy, - grid + res <- layout_fruchterman_reingold_impl( + graph = graph, + coords = coords, + use_seed = !is.null(coords), + niter = niter, + start_temp = start.temp, + grid = grid, + weights = weights, + minx = minx, + maxx = maxx, + miny = miny, + maxy = maxy ) } else { - res <- .Call( # layout_fruchterman_reingold_3d_impl has different API - Rx_igraph_layout_fruchterman_reingold_3d, - graph, - coords, - niter, - start.temp, - weights, - minx, - maxx, - miny, - maxy, - minz, - maxz + res <- layout_fruchterman_reingold_3d_impl( + graph = graph, + coords = coords, + use_seed = !is.null(coords), + niter = niter, + start_temp = start.temp, + weights = weights, + minx = minx, + maxx = maxx, + miny = miny, + maxy = maxy, + minz = minz, + maxz = maxz ) } res @@ -1766,17 +1764,16 @@ layout_with_graphopt <- function( spring.constant <- as.double(spring.constant) max.sa.movement <- as.double(max.sa.movement) - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # layout_graphopt_impl has different API - Rx_igraph_layout_graphopt, - graph, - niter, - charge, - mass, - spring.length, - spring.constant, - max.sa.movement, - start + layout_graphopt_impl( + graph = graph, + res = start, + niter = niter, + node_charge = charge, + node_mass = mass, + spring_length = spring.length, + spring_constant = spring.constant, + max_sa_movement = max.sa.movement, + use_seed = TRUE ) } @@ -1881,8 +1878,15 @@ layout_with_kk <- function( } ensure_igraph(graph) - coords[] <- as.numeric(coords) dim <- igraph_match_arg(dim) + use_seed <- !is.null(coords) + if (is.null(coords)) { + # Initialize coords with zeros - will be ignored if use_seed=FALSE + n <- vcount(graph) + dim_n <- if (dim == "2") 2 else 3 + coords <- matrix(0, n, dim_n) + } + coords[] <- as.numeric(coords) maxiter <- as.numeric(maxiter) epsilon <- as.numeric(epsilon) @@ -1927,37 +1931,36 @@ layout_with_kk <- function( lifecycle::deprecate_stop("0.8.0", "layout_with_kk(coolexp = )") } - on.exit(.Call(Rx_igraph_finalizer)) # Function call if (dim == 2) { - res <- .Call( # layout_kamada_kawai_impl has different API - Rx_igraph_layout_kamada_kawai, - graph, - coords, - maxiter, - epsilon, - kkconst, - weights, - minx, - maxx, - miny, - maxy + res <- layout_kamada_kawai_impl( + graph = graph, + coords = coords, + use_seed = use_seed, + maxiter = maxiter, + epsilon = epsilon, + kkconst = kkconst, + weights = weights, + minx = minx, + maxx = maxx, + miny = miny, + maxy = maxy ) } else { - res <- .Call( # layout_kamada_kawai_3d_impl has different API - Rx_igraph_layout_kamada_kawai_3d, - graph, - coords, - maxiter, - epsilon, - kkconst, - weights, - minx, - maxx, - miny, - maxy, - minz, - maxz + res <- layout_kamada_kawai_3d_impl( + graph = graph, + coords = coords, + use_seed = use_seed, + maxiter = maxiter, + epsilon = epsilon, + kkconst = kkconst, + weights = weights, + minx = minx, + maxx = maxx, + miny = miny, + maxy = maxy, + minz = minz, + maxz = maxz ) } @@ -2037,17 +2040,15 @@ layout_with_lgl <- function( root <- as_igraph_vs(graph, root) - 1 } - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # layout_lgl_impl has different API - Rx_igraph_layout_lgl, - graph, - as.double(maxiter), - as.double(maxdelta), - as.double(area), - as.double(coolexp), - as.double(repulserad), - as.double(cellsize), - root + layout_lgl_impl( + graph = graph, + maxiter = maxiter, + maxdelta = maxdelta, + area = area, + coolexp = coolexp, + repulserad = repulserad, + cellsize = cellsize, + root = root ) } @@ -2549,11 +2550,9 @@ merge_coords <- function(graphs, layouts, method = "dla") { cli::cli_abort("{.arg method} must be {.str dla}, not {.str {method}}.") } - on.exit(.Call(Rx_igraph_finalizer)) - .Call( # layout_merge_dla_impl has different API - Rx_igraph_layout_merge_dla, - graphs, - layouts + layout_merge_dla_impl( + graphs = graphs, + coords = layouts ) } @@ -2891,24 +2890,21 @@ layout_with_drl <- function( weights <- NULL } - on.exit(.Call(Rx_igraph_finalizer)) if (dim == 2) { - res <- .Call( # layout_drl_impl has different API - Rx_igraph_layout_drl, - graph, - seed, - use.seed, - options, - weights + res <- layout_drl_impl( + graph = graph, + res = seed, + use_seed = use.seed, + options = options, + weights = weights ) } else { - res <- .Call( # layout_drl_3d_impl has different API - Rx_igraph_layout_drl_3d, - graph, - seed, - use.seed, - options, - weights + res <- layout_drl_3d_impl( + graph = graph, + res = seed, + use_seed = use.seed, + options = options, + weights = weights ) } res diff --git a/R/print.R b/R/print.R index 932ccf47b13..d72292332cf 100644 --- a/R/print.R +++ b/R/print.R @@ -33,7 +33,7 @@ sep = "", gal, " (g/", - .Call(Rx_igraph_get_attr_mode, object, 2L) # internal, no _impl, + .Call(Rx_igraph_get_attr_mode, object, 2L), # internal, no _impl ")" ) } @@ -43,7 +43,7 @@ sep = "", val, " (v/", - .Call(Rx_igraph_get_attr_mode, object, 3L) # internal, no _impl, + .Call(Rx_igraph_get_attr_mode, object, 3L), # internal, no _impl ")" ) } @@ -53,7 +53,7 @@ sep = "", edge_attr_names(object), " (e/", - .Call(Rx_igraph_get_attr_mode, object, 4L) # internal, no _impl, + .Call(Rx_igraph_get_attr_mode, object, 4L), # internal, no _impl ")" ) } diff --git a/R/topology.R b/R/topology.R index 1ef9f628b06..cf258d004ec 100644 --- a/R/topology.R +++ b/R/topology.R @@ -220,7 +220,7 @@ graph.subisomorphic.lad <- function( on.exit(.Call(Rx_igraph_finalizer)) # Function call - res <- .Call( # subisomorphic_lad_impl has different API + res <- .Call( # subisomorphic_lad_impl lacks map/all.maps parameters Rx_igraph_subisomorphic_lad, pattern, target, From c4ab986da9c4a559e4519e7f0750485c5493ce2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:49:56 +0000 Subject: [PATCH 13/15] Fix layout functions to properly initialize coords when NULL before calling _impl Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/layout.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/R/layout.R b/R/layout.R index 42b31909384..e346c02bb14 100644 --- a/R/layout.R +++ b/R/layout.R @@ -1517,8 +1517,15 @@ layout_with_fr <- function( ) { # Argument checks ensure_igraph(graph) - coords[] <- as.numeric(coords) dim <- igraph_match_arg(dim) + use_seed <- !is.null(coords) + if (is.null(coords)) { + # Initialize coords with zeros - will be ignored if use_seed=FALSE + n <- vcount(graph) + dim_n <- if (dim == "2") 2 else 3 + coords <- matrix(0, n, dim_n) + } + coords[] <- as.numeric(coords) if (!missing(niter) && !missing(maxiter)) { cli::cli_abort(c( "{.arg niter} and {.arg maxiter} must not be specified at the same time.", @@ -1576,7 +1583,7 @@ layout_with_fr <- function( res <- layout_fruchterman_reingold_impl( graph = graph, coords = coords, - use_seed = !is.null(coords), + use_seed = use_seed, niter = niter, start_temp = start.temp, grid = grid, @@ -1590,7 +1597,7 @@ layout_with_fr <- function( res <- layout_fruchterman_reingold_3d_impl( graph = graph, coords = coords, - use_seed = !is.null(coords), + use_seed = use_seed, niter = niter, start_temp = start.temp, weights = weights, From 31579a380a5857513b083fb5b69c9fea13d916d9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:52:18 +0000 Subject: [PATCH 14/15] Fix weight handling in layout functions to let _impl handle defaults Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/layout.R | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/R/layout.R b/R/layout.R index e346c02bb14..5be6ba8888a 100644 --- a/R/layout.R +++ b/R/layout.R @@ -1540,14 +1540,8 @@ layout_with_fr <- function( grid <- igraph_match_arg(grid) - if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { - weights <- E(graph)$weight - } - if (!is.null(weights) && any(!is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL - } + # Let _impl handle default weights from edge attribute + # Pass weights as-is (including NA to signal "no weights") if (!is.null(minx)) { minx <- as.numeric(minx) } @@ -1763,6 +1757,11 @@ layout_with_graphopt <- function( max.sa.movement = 5 ) { ensure_igraph(graph) + use_seed <- !is.null(start) + if (is.null(start)) { + # Initialize with zeros - will be ignored if use_seed=FALSE + start <- matrix(0, vcount(graph), 2) + } start[] <- as.numeric(start) niter <- as.double(niter) charge <- as.double(charge) @@ -1780,7 +1779,7 @@ layout_with_graphopt <- function( spring_length = spring.length, spring_constant = spring.constant, max_sa_movement = max.sa.movement, - use_seed = TRUE + use_seed = use_seed ) } From a524504403d71a8c413af7898ad31292c73e9629 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:57:42 +0000 Subject: [PATCH 15/15] Revert some foreign.R functions to .Call() due to _impl bugs or different semantics Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- R/foreign.R | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/R/foreign.R b/R/foreign.R index 7b58975a3d5..bfe57d9afc2 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -549,13 +549,20 @@ read.graph.ncol <- function( weights = c("auto", "yes", "no"), directed = FALSE ) { - weights <- igraph_match_arg(weights) - read_graph_ncol_impl( - instream = file, - predefnames = predef, - names = names, - weights = switch(weights, "no" = FALSE, "yes" = TRUE, "auto" = NA), - directed = directed + weights <- switch( + igraph_match_arg(weights), + "no" = 0L, + "yes" = 1L, + "auto" = 2L + ) + on.exit(.Call(Rx_igraph_finalizer)) + .Call( # read_graph_ncol_impl has bug with predefnames + Rx_igraph_read_graph_ncol, + file, + as.character(predef), + as.logical(names), + weights, + as.logical(directed) ) } @@ -574,11 +581,13 @@ write.graph.ncol <- function( weights <- NULL } - write_graph_ncol_impl( - graph = graph, - outstream = file, - names = names, - weights = weights + on.exit(.Call(Rx_igraph_finalizer)) + .Call( # write_graph_ncol_impl can't handle NULL names/weights + Rx_igraph_write_graph_ncol, + graph, + file, + names, + weights ) } @@ -613,12 +622,14 @@ write.graph.lgl <- function( weights <- NULL } - write_graph_lgl_impl( - graph = graph, - outstream = file, - names = names, - weights = weights, - isolates = isolates + on.exit(.Call(Rx_igraph_finalizer)) + .Call( # write_graph_lgl_impl can't handle NULL names/weights + Rx_igraph_write_graph_lgl, + graph, + file, + names, + weights, + as.logical(isolates) ) }