Skip to content

Commit 43f14d3

Browse files
committed
refactor: make_empty_graph() is now fully auto-generated
1 parent 5dd1e4e commit 43f14d3

2 files changed

Lines changed: 1 addition & 50 deletions

File tree

R/make.R

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -698,25 +698,7 @@ undirected_graph <- function(...) constructor_spec(make_undirected_graph, ...)
698698
#' @examples
699699
#' make_empty_graph(n = 10)
700700
#' make_empty_graph(n = 5, directed = FALSE)
701-
make_empty_graph <- function(n = 0, directed = TRUE) {
702-
# Argument checks
703-
if (is.null(n)) {
704-
stop("number of vertices must be an integer")
705-
}
706-
707-
n <- suppressWarnings(as.numeric(n))
708-
if (is.na(n)) {
709-
stop("number of vertices must be an integer")
710-
}
711-
712-
directed <- as.logical(directed)
713-
714-
on.exit(.Call(R_igraph_finalizer))
715-
# Function call
716-
res <- .Call(R_igraph_empty, n, directed)
717-
718-
res
719-
}
701+
make_empty_graph <- empty_impl
720702

721703
#' @rdname make_empty_graph
722704
#' @param ... Passed to `make_graph_empty`.

src/rinterface.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -162,37 +162,6 @@ SEXP R_igraph_vcount(SEXP graph) {
162162
return(r_result);
163163
}
164164

165-
/*-------------------------------------------/
166-
/ igraph_empty_attrs /
167-
/-------------------------------------------*/
168-
SEXP R_igraph_empty_attrs(SEXP n, SEXP directed) {
169-
/* Declarations */
170-
igraph_t c_graph;
171-
igraph_integer_t c_n;
172-
igraph_bool_t c_directed;
173-
174-
SEXP graph;
175-
176-
SEXP r_result;
177-
/* Convert input */
178-
IGRAPH_R_CHECK_INT(n);
179-
c_n = (igraph_integer_t) REAL(n)[0];
180-
IGRAPH_R_CHECK_BOOL(directed);
181-
c_directed = LOGICAL(directed)[0];
182-
/* Call igraph */
183-
IGRAPH_R_CHECK(igraph_empty_attrs(&c_graph, c_n, c_directed, 0));
184-
185-
/* Convert output */
186-
IGRAPH_FINALLY(igraph_destroy, &c_graph);
187-
PROTECT(graph=R_igraph_to_SEXP(&c_graph));
188-
IGRAPH_I_DESTROY(&c_graph);
189-
IGRAPH_FINALLY_CLEAN(1);
190-
r_result = graph;
191-
192-
UNPROTECT(1);
193-
return(r_result);
194-
}
195-
196165
/*-------------------------------------------/
197166
/ igraph_get_all_eids_between /
198167
/-------------------------------------------*/

0 commit comments

Comments
 (0)