From f87a91c1c5c500757de8cf348c9141c62b8bd081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Fri, 29 Dec 2023 22:25:30 +0100 Subject: [PATCH] Un-ignore R+C 2 --- R/aaa-auto.R | 11 +++++++++++ src/cpp11.cpp | 2 ++ src/rinterface.c | 27 +++++++++++++++++++++++++++ tools/stimulus/functions-R.yaml | 1 - 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 4a02754a5f..e962b0800f 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -13,6 +13,17 @@ empty_impl <- function(n=0, directed=TRUE) { res } +add_edges_impl <- function(graph, edges) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_add_edges, graph, edges) + + res +} + copy_impl <- function(from) { # Argument checks ensure_igraph(from) diff --git a/src/cpp11.cpp b/src/cpp11.cpp index c1bdd9a6fe..ef691f87be 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -22,6 +22,7 @@ extern "C" SEXP _igraph_getsphere(SEXP spos, SEXP sradius, SEXP scolor, SEXP lig extern "C" { /* .Call calls */ +extern SEXP R_igraph_add_edges(void *, void *); extern SEXP R_igraph_add_edges_manual(void *, void *); extern SEXP R_igraph_add_env(void *); extern SEXP R_igraph_add_myid_to_env(void *); @@ -480,6 +481,7 @@ extern SEXP promise_env_(void *); extern SEXP promise_expr_(void *); static const R_CallMethodDef CallEntries[] = { + {"R_igraph_add_edges", (DL_FUNC) &R_igraph_add_edges, 2}, {"R_igraph_add_edges_manual", (DL_FUNC) &R_igraph_add_edges_manual, 2}, {"R_igraph_add_env", (DL_FUNC) &R_igraph_add_env, 1}, {"R_igraph_add_myid_to_env", (DL_FUNC) &R_igraph_add_myid_to_env, 1}, diff --git a/src/rinterface.c b/src/rinterface.c index 12a9d2a527..c531e53444 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -58,6 +58,33 @@ SEXP R_igraph_empty(SEXP n, SEXP directed) { return(r_result); } +/*-------------------------------------------/ +/ igraph_add_edges / +/-------------------------------------------*/ +SEXP R_igraph_add_edges(SEXP graph, SEXP edges) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_edges; + + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + R_SEXP_to_vector_int_copy(edges, &c_edges); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_add_edges(&c_graph, &c_edges, 0)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_copy / /-------------------------------------------*/ diff --git a/tools/stimulus/functions-R.yaml b/tools/stimulus/functions-R.yaml index 42a738ec7f..e70242eacb 100644 --- a/tools/stimulus/functions-R.yaml +++ b/tools/stimulus/functions-R.yaml @@ -17,7 +17,6 @@ igraph_empty_attrs: IGNORE: RR, RC igraph_add_edges: - IGNORE: RR, RC, RInit igraph_add_vertices: IGNORE: RR, RC, RInit