From aae2c2d44ed7aa7775a4b52b4f3a56282dbe551f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 18 Dec 2023 12:15:38 +0100 Subject: [PATCH 01/13] ci: go back to stricter checks --- .github/workflows/build-and-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index d1c27a4916..b7d7fccab1 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -172,7 +172,7 @@ jobs: - name: Check R package uses: r-lib/actions/check-r-package@v2 with: - error-on: '"error"' + error-on: '"note"' coverage: runs-on: ubuntu-20.04 From 167c46e06e2976dff080d1e81f2bd194c34005be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 11 Jan 2024 20:04:50 +0100 Subject: [PATCH 02/13] Remove autogenerated dead code --- R/aaa-auto.R | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 603dfb99e0..78f3e969d4 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -2703,26 +2703,6 @@ from_hrg_dendrogram_impl <- function(hrg) { res } -get_adjacency_sparse_impl <- function(graph, type=c("both", "upper", "lower"), weights=NULL, loops=ONCE) { - # Argument checks - ensure_igraph(graph) - type <- switch(igraph.match.arg(type), "upper"=0L, "lower"=1L, "both"=2L) - 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 - } - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_get_adjacency_sparse, graph, type, weights, loops) - - res -} - get_stochastic_sparse_impl <- function(graph, column.wise=FALSE, weights=NULL) { # Argument checks ensure_igraph(graph) From 6a8a0b89c7c9e0869cbc528799820907b7232c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 11 Jan 2024 20:12:50 +0100 Subject: [PATCH 03/13] Fix documentation --- R/structural.properties.R | 1 + man/k_shortest_paths.Rd | 2 ++ 2 files changed, 3 insertions(+) diff --git a/R/structural.properties.R b/R/structural.properties.R index ab1c44eef8..287aaa20cb 100644 --- a/R/structural.properties.R +++ b/R/structural.properties.R @@ -1067,6 +1067,7 @@ all_shortest_paths <- function(graph, from, #' @param to The target vertex of the shortest paths. #' @param k The number of paths to find. They will be returned in order of #' increasing length. +#' @inheritParams rlang::args_dots_empty #' @inheritParams shortest_paths #' @return A named list with two components is returned: #' \item{vpaths}{The list of \eqn{k} shortest paths in terms of vertices} diff --git a/man/k_shortest_paths.Rd b/man/k_shortest_paths.Rd index 15b6b77fbd..407077cbf1 100644 --- a/man/k_shortest_paths.Rd +++ b/man/k_shortest_paths.Rd @@ -21,6 +21,8 @@ k_shortest_paths( \item{to}{The target vertex of the shortest paths.} +\item{...}{These dots are for future extensions and must be empty.} + \item{k}{The number of paths to find. They will be returned in order of increasing length.} From 3a29728f155ee581ad5567217a38897a83c3ab6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 11 Jan 2024 20:13:14 +0100 Subject: [PATCH 04/13] Autogenerate cpp11 glue --- src/cpp11.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cpp11.cpp b/src/cpp11.cpp index a2fbc2967b..a33529d07d 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -175,7 +175,6 @@ extern SEXP R_igraph_full_multipartite(void *, void *, void *); extern SEXP R_igraph_fundamental_cycles(void *, void *, void *, void *); extern SEXP R_igraph_generalized_petersen(void *, void *); extern SEXP R_igraph_get_adjacency(void *, void *, void *, void *); -extern SEXP R_igraph_get_adjacency_sparse(void *, void *, void *, void *); extern SEXP R_igraph_get_adjedgelist(void *, void *, void *); extern SEXP R_igraph_get_adjlist(void *, void *, void *, void *); extern SEXP R_igraph_get_all_eids_between(void *, void *, void *, void *); @@ -643,7 +642,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_fundamental_cycles", (DL_FUNC) &R_igraph_fundamental_cycles, 4}, {"R_igraph_generalized_petersen", (DL_FUNC) &R_igraph_generalized_petersen, 2}, {"R_igraph_get_adjacency", (DL_FUNC) &R_igraph_get_adjacency, 4}, - {"R_igraph_get_adjacency_sparse", (DL_FUNC) &R_igraph_get_adjacency_sparse, 4}, {"R_igraph_get_adjedgelist", (DL_FUNC) &R_igraph_get_adjedgelist, 3}, {"R_igraph_get_adjlist", (DL_FUNC) &R_igraph_get_adjlist, 4}, {"R_igraph_get_all_eids_between", (DL_FUNC) &R_igraph_get_all_eids_between, 4}, From 444193f9727d4c644f844be06e20052352bd3e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 11 Jan 2024 23:15:16 +0100 Subject: [PATCH 05/13] Use sh --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 771fc02144..db33b2140d 100755 --- a/configure +++ b/configure @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Use pkg-config or xml2-config to get the include directory for libxml-2.0 xml2_include_dir="" @@ -11,7 +11,7 @@ else exit 1 fi -if [[ -n "$xml2_include_dir" ]]; then +if [ -n "$xml2_include_dir" ]; then PKG_CFLAGS="-I\"$xml2_include_dir\"" echo "libxml2 include directory: $xml2_include_dir" else From be4e0a9c907b0821a9ac59e82a0aba4633d547cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 11 Jan 2024 23:18:12 +0100 Subject: [PATCH 06/13] Tweak Makevars --- src/Makevars.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Makevars.in b/src/Makevars.in index 11db2342e9..f7fcaa3b12 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -4,12 +4,11 @@ PKG_CFLAGS=$(C_VISIBILITY) PKG_CXXFLAGS=$(CXX_VISIBILITY) PKG_FFLAGS=$(F_VISIBILITY) -PKG_CPPFLAGS=@cflags@ -DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor \ +PKG_CPPFLAGS=-DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor @cflags@ \ -DNDEBUG -DNTIMER -DNPRINT -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL= \ -DPRPACK_IGRAPH_SUPPORT \ -D_GNU_SOURCE=1 -PKG_LIBS = -L"${LIB_XML}/lib" -lxml2 -lz -L"${GLPK_HOME}/lib" \ - -lglpk -lgmp -L"${LIB_GMP}/lib" $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) +PKG_LIBS = -lxml2 -lz -lglpk -lgmp $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) OBJECTS=${SOURCES} From d29a598fb8432788f35d533742fee9471bc6f2cd Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Sat, 13 Jan 2024 14:41:15 +0100 Subject: [PATCH 07/13] fix: remove broken functions --- R/aaa-auto.R | 80 +------------- src/cpp11.cpp | 12 --- src/rinterface.c | 201 ++--------------------------------- tools/stimulus/types-RC.yaml | 10 ++ 4 files changed, 18 insertions(+), 285 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 78f3e969d4..d7a5535890 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -969,7 +969,7 @@ edge_betweenness_subset_impl <- function(graph, eids=E(graph), directed=TRUE, so on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_edge_betweenness_subset, graph, eids-1, directed, sources-1, targets-1, weights) - if (igraph_opt("add.vertex.names") && is_named(graph)) { +if (igraph_opt("add.vertex.names") && is_named(graph)) { names(res) <- vertex_attr(graph, "name", V(graph)) } res @@ -2297,25 +2297,6 @@ largest_cliques_impl <- function(graph) { res } -maximal_cliques_subset_impl <- function(graph, subset, outfile=NULL, min.size=0, max.size=0, details=FALSE) { - # Argument checks - ensure_igraph(graph) - subset <- as_igraph_vs(graph, subset) - min.size <- as.numeric(min.size) - max.size <- as.numeric(max.size) - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_maximal_cliques_subset, graph, subset-1, outfile, min.size, max.size) - if (igraph_opt("return.vs.es")) { - res$res <- lapply(res$res, unsafe_create_vs, graph = graph, verts = V(graph)) - } - if (!details) { - res <- res$res - } - res -} - maximal_cliques_hist_impl <- function(graph, min.size=0, max.size=0) { # Argument checks ensure_igraph(graph) @@ -3595,30 +3576,6 @@ dim_select_impl <- function(sv) { res } -almost_equals_impl <- function(a, b, eps) { - # Argument checks - - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_almost_equals, a, b, eps) - - - res -} - -cmp_epsilon_impl <- function(a, b, eps) { - # Argument checks - - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_cmp_epsilon, a, b, eps) - - - res -} - solve_lsap_impl <- function(c, n) { # Argument checks c[] <- as.numeric(c) @@ -3918,41 +3875,6 @@ stochastic_imitation_impl <- function(graph, vid, algo, quantities, strategies, res } -progress_impl <- function(message, percent) { - # Argument checks - percent <- as.numeric(percent) - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_progress, message, percent) - - - res -} - -status_impl <- function(message) { - # Argument checks - - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_status, message) - - - res -} - -strerror_impl <- function(igraph.errno) { - # Argument checks - - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_strerror, igraph.errno) - - - res -} vertex_path_from_edge_path_impl <- function(graph, start, edge.path, mode=c("out", "in", "all", "total")) { # Argument checks diff --git a/src/cpp11.cpp b/src/cpp11.cpp index a33529d07d..0f1353a391 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -30,7 +30,6 @@ extern SEXP R_igraph_adjlist(void *, void *, void *); extern SEXP R_igraph_all_minimal_st_separators(void *); extern SEXP R_igraph_all_st_cuts(void *, void *, void *); extern SEXP R_igraph_all_st_mincuts(void *, void *, void *, void *); -extern SEXP R_igraph_almost_equals(void *, void *, void *); extern SEXP R_igraph_are_connected(void *, void *, void *); extern SEXP R_igraph_arpack(void *, void *, void *, void *, void *); extern SEXP R_igraph_arpack_unpack_complex(void *, void *, void *); @@ -78,7 +77,6 @@ extern SEXP R_igraph_clique_number(void *); extern SEXP R_igraph_clique_size_hist(void *, void *, void *); extern SEXP R_igraph_cliques(void *, void *, void *); extern SEXP R_igraph_closeness_cutoff(void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_cmp_epsilon(void *, void *, void *); extern SEXP R_igraph_cocitation(void *, void *); extern SEXP R_igraph_cohesion(void *, void *); extern SEXP R_igraph_cohesive_blocks(void *); @@ -324,7 +322,6 @@ extern SEXP R_igraph_maximal_cliques(void *, void *, void *, void *); extern SEXP R_igraph_maximal_cliques_count(void *, void *, void *, void *); extern SEXP R_igraph_maximal_cliques_file(void *, void *, void *, void *, void *); extern SEXP R_igraph_maximal_cliques_hist(void *, void *, void *); -extern SEXP R_igraph_maximal_cliques_subset(void *, void *, void *, void *, void *); extern SEXP R_igraph_maximal_independent_vertex_sets(void *); extern SEXP R_igraph_maximum_bipartite_matching(void *, void *, void *, void *); extern SEXP R_igraph_maximum_cardinality_search(void *); @@ -356,7 +353,6 @@ extern SEXP R_igraph_personalized_pagerank(void *, void *, void *, void *, void extern SEXP R_igraph_personalized_pagerank_vs(void *, void *, void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_power_law_fit(void *, void *, void *); extern SEXP R_igraph_preference_game(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_progress(void *, void *); extern SEXP R_igraph_pseudo_diameter(void *, void *, void *, void *); extern SEXP R_igraph_pseudo_diameter_dijkstra(void *, void *, void *, void *, void *); extern SEXP R_igraph_radius(void *, void *); @@ -419,10 +415,8 @@ extern SEXP R_igraph_st_vertex_connectivity(void *, void *, void *); extern SEXP R_igraph_star(void *, void *, void *); extern SEXP R_igraph_static_fitness_game(void *, void *, void *, void *, void *); extern SEXP R_igraph_static_power_law_game(void *, void *, void *, void *, void *, void *, void *); -extern SEXP R_igraph_status(void *); extern SEXP R_igraph_stochastic_imitation(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_strength(void *, void *, void *, void *, void *); -extern SEXP R_igraph_strerror(void *); extern SEXP R_igraph_subcomponent(void *, void *, void *); extern SEXP R_igraph_subgraph_from_edges(void *, void *, void *); extern SEXP R_igraph_subisomorphic(void *, void *); @@ -497,7 +491,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_all_minimal_st_separators", (DL_FUNC) &R_igraph_all_minimal_st_separators, 1}, {"R_igraph_all_st_cuts", (DL_FUNC) &R_igraph_all_st_cuts, 3}, {"R_igraph_all_st_mincuts", (DL_FUNC) &R_igraph_all_st_mincuts, 4}, - {"R_igraph_almost_equals", (DL_FUNC) &R_igraph_almost_equals, 3}, {"R_igraph_are_connected", (DL_FUNC) &R_igraph_are_connected, 3}, {"R_igraph_arpack", (DL_FUNC) &R_igraph_arpack, 5}, {"R_igraph_arpack_unpack_complex", (DL_FUNC) &R_igraph_arpack_unpack_complex, 3}, @@ -545,7 +538,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_clique_size_hist", (DL_FUNC) &R_igraph_clique_size_hist, 3}, {"R_igraph_cliques", (DL_FUNC) &R_igraph_cliques, 3}, {"R_igraph_closeness_cutoff", (DL_FUNC) &R_igraph_closeness_cutoff, 6}, - {"R_igraph_cmp_epsilon", (DL_FUNC) &R_igraph_cmp_epsilon, 3}, {"R_igraph_cocitation", (DL_FUNC) &R_igraph_cocitation, 2}, {"R_igraph_cohesion", (DL_FUNC) &R_igraph_cohesion, 2}, {"R_igraph_cohesive_blocks", (DL_FUNC) &R_igraph_cohesive_blocks, 1}, @@ -791,7 +783,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_maximal_cliques_count", (DL_FUNC) &R_igraph_maximal_cliques_count, 4}, {"R_igraph_maximal_cliques_file", (DL_FUNC) &R_igraph_maximal_cliques_file, 5}, {"R_igraph_maximal_cliques_hist", (DL_FUNC) &R_igraph_maximal_cliques_hist, 3}, - {"R_igraph_maximal_cliques_subset", (DL_FUNC) &R_igraph_maximal_cliques_subset, 5}, {"R_igraph_maximal_independent_vertex_sets", (DL_FUNC) &R_igraph_maximal_independent_vertex_sets, 1}, {"R_igraph_maximum_bipartite_matching", (DL_FUNC) &R_igraph_maximum_bipartite_matching, 4}, {"R_igraph_maximum_cardinality_search", (DL_FUNC) &R_igraph_maximum_cardinality_search, 1}, @@ -823,7 +814,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_personalized_pagerank_vs", (DL_FUNC) &R_igraph_personalized_pagerank_vs, 8}, {"R_igraph_power_law_fit", (DL_FUNC) &R_igraph_power_law_fit, 3}, {"R_igraph_preference_game", (DL_FUNC) &R_igraph_preference_game, 7}, - {"R_igraph_progress", (DL_FUNC) &R_igraph_progress, 2}, {"R_igraph_pseudo_diameter", (DL_FUNC) &R_igraph_pseudo_diameter, 4}, {"R_igraph_pseudo_diameter_dijkstra", (DL_FUNC) &R_igraph_pseudo_diameter_dijkstra, 5}, {"R_igraph_radius", (DL_FUNC) &R_igraph_radius, 2}, @@ -886,10 +876,8 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_star", (DL_FUNC) &R_igraph_star, 3}, {"R_igraph_static_fitness_game", (DL_FUNC) &R_igraph_static_fitness_game, 5}, {"R_igraph_static_power_law_game", (DL_FUNC) &R_igraph_static_power_law_game, 7}, - {"R_igraph_status", (DL_FUNC) &R_igraph_status, 1}, {"R_igraph_stochastic_imitation", (DL_FUNC) &R_igraph_stochastic_imitation, 6}, {"R_igraph_strength", (DL_FUNC) &R_igraph_strength, 5}, - {"R_igraph_strerror", (DL_FUNC) &R_igraph_strerror, 1}, {"R_igraph_subcomponent", (DL_FUNC) &R_igraph_subcomponent, 3}, {"R_igraph_subgraph_from_edges", (DL_FUNC) &R_igraph_subgraph_from_edges, 3}, {"R_igraph_subisomorphic", (DL_FUNC) &R_igraph_subisomorphic, 2}, diff --git a/src/rinterface.c b/src/rinterface.c index cdc0d16171..6384be4fbd 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -6317,56 +6317,6 @@ SEXP R_igraph_largest_cliques(SEXP graph) { return(r_result); } -/*-------------------------------------------/ -/ igraph_maximal_cliques_subset / -/-------------------------------------------*/ -SEXP R_igraph_maximal_cliques_subset(SEXP graph, SEXP subset, SEXP outfile, SEXP min_size, SEXP max_size) { - /* Declarations */ - igraph_t c_graph; - igraph_vector_int_t c_subset; - igraph_vector_int_list_t c_res; - igraph_integer_t c_no; - FILE* c_outfile; - igraph_integer_t c_min_size; - igraph_integer_t c_max_size; - SEXP res; - SEXP no; - - SEXP r_result, r_names; - /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector_int_copy(subset, &c_subset); - if (0 != igraph_vector_int_list_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); - c_no=0; - IGRAPH_R_CHECK_INT(min_size); - c_min_size = (igraph_integer_t) REAL(min_size)[0]; - IGRAPH_R_CHECK_INT(max_size); - c_max_size = (igraph_integer_t) REAL(max_size)[0]; - /* Call igraph */ - IGRAPH_R_CHECK(igraph_maximal_cliques_subset(&c_graph, &c_subset, &c_res, &c_no, c_outfile, c_min_size, c_max_size)); - - /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); - igraph_vector_int_list_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(no=NEW_NUMERIC(1)); - REAL(no)[0]=(double) c_no; - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, no); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("no")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); - - UNPROTECT(1); - return(r_result); -} - /*-------------------------------------------/ / igraph_maximal_cliques_hist / /-------------------------------------------*/ @@ -8419,37 +8369,6 @@ SEXP R_igraph_read_graph_dimacs_flow(SEXP instream, SEXP directed) { return(r_result); } -/*-------------------------------------------/ -/ igraph_write_graph_dimacs_flow / -/-------------------------------------------*/ -SEXP R_igraph_write_graph_dimacs_flow(SEXP graph, SEXP outstream, SEXP source, SEXP target, SEXP capacity) { - /* Declarations */ - igraph_t c_graph; - FILE* c_outstream; - igraph_integer_t c_source; - igraph_integer_t c_target; - igraph_vector_t c_capacity; - - SEXP r_result; - /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - c_source = (igraph_integer_t) REAL(source)[0]; - c_target = (igraph_integer_t) REAL(target)[0]; - R_SEXP_to_vector(capacity, &c_capacity); - /* Call igraph */ - IGRAPH_R_CHECK(igraph_write_graph_dimacs_flow(&c_graph, c_outstream, c_source, c_target, &c_capacity)); - - /* 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_dyad_census / /-------------------------------------------*/ @@ -10870,52 +10789,6 @@ SEXP R_igraph_dim_select(SEXP sv) { return(r_result); } -/*-------------------------------------------/ -/ igraph_almost_equals / -/-------------------------------------------*/ -SEXP R_igraph_almost_equals(SEXP a, SEXP b, SEXP eps) { - /* Declarations */ - double c_a; - double c_b; - double c_eps; - igraph_bool_t c_result; - SEXP r_result; - /* Convert input */ - - /* Call igraph */ - c_result=igraph_almost_equals(c_a, c_b, c_eps); - - /* Convert output */ - - PROTECT(r_result=NEW_LOGICAL(1)); - LOGICAL(r_result)[0]=c_result; - - UNPROTECT(1); - return(r_result); -} - -/*-------------------------------------------/ -/ igraph_cmp_epsilon / -/-------------------------------------------*/ -SEXP R_igraph_cmp_epsilon(SEXP a, SEXP b, SEXP eps) { - /* Declarations */ - double c_a; - double c_b; - double c_eps; - int c_result; - SEXP r_result; - /* Convert input */ - - /* Call igraph */ - c_result=igraph_cmp_epsilon(c_a, c_b, c_eps); - - /* Convert output */ - - - - UNPROTECT(1); - return(r_result); -} /*-------------------------------------------/ / igraph_solve_lsap / @@ -11586,73 +11459,6 @@ SEXP R_igraph_has_attribute_table() { return(r_result); } -/*-------------------------------------------/ -/ igraph_progress / -/-------------------------------------------*/ -SEXP R_igraph_progress(SEXP message, SEXP percent) { - /* Declarations */ - const char* c_message; - igraph_real_t c_percent; - - igraph_error_t c_result; - SEXP r_result; - /* Convert input */ - IGRAPH_R_CHECK_REAL(percent); - c_percent = REAL(percent)[0]; - /* Call igraph */ - IGRAPH_R_CHECK(igraph_progress(c_message, c_percent, 0)); - - /* Convert output */ - - - - UNPROTECT(1); - return(r_result); -} - -/*-------------------------------------------/ -/ igraph_status / -/-------------------------------------------*/ -SEXP R_igraph_status(SEXP message) { - /* Declarations */ - const char* c_message; - - igraph_error_t c_result; - SEXP r_result; - /* Convert input */ - - /* Call igraph */ - IGRAPH_R_CHECK(igraph_status(c_message, 0)); - - /* Convert output */ - - - - UNPROTECT(1); - return(r_result); -} - -/*-------------------------------------------/ -/ igraph_strerror / -/-------------------------------------------*/ -SEXP R_igraph_strerror(SEXP igraph_errno) { - /* Declarations */ - igraph_error_t c_igraph_errno; - const char* c_result; - SEXP r_result; - /* Convert input */ - - /* Call igraph */ - c_result=igraph_strerror(c_igraph_errno); - - /* Convert output */ - - - - UNPROTECT(1); - return(r_result); -} - /*-------------------------------------------/ / igraph_expand_path_to_pairs / /-------------------------------------------*/ @@ -11758,6 +11564,13 @@ SEXP R_igraph_version() { /* Convert output */ PROTECT(r_result=NEW_LIST(4)); PROTECT(r_names=NEW_CHARACTER(4)); + PROTECT(version_string = Rf_mkCharLenCE(c_version_string, strlen(c_version_string), CE_UTF8)); + PROTECT(major=NEW_INTEGER(1)); + INTEGER(major)[0]=(int) c_major; + PROTECT(minor=NEW_INTEGER(1)); + INTEGER(minor)[0]=(int) c_minor; + PROTECT(subminor=NEW_INTEGER(1)); + INTEGER(subminor)[0]=(int) c_subminor; SET_VECTOR_ELT(r_result, 0, version_string); SET_VECTOR_ELT(r_result, 1, major); SET_VECTOR_ELT(r_result, 2, minor); diff --git a/tools/stimulus/types-RC.yaml b/tools/stimulus/types-RC.yaml index 723eafb809..5ca2fc224e 100644 --- a/tools/stimulus/types-RC.yaml +++ b/tools/stimulus/types-RC.yaml @@ -58,6 +58,10 @@ INT: IN: |- IGRAPH_R_CHECK_INT(%I%); %C% = INTEGER(%I%)[0]; + OUTCONV: + OUT: |- + PROTECT(%I%=NEW_INTEGER(1)); + INTEGER(%I%)[0]=(int) %C%; CSTRING: CTYPE: const char* @@ -65,6 +69,12 @@ CSTRING: IN: '%C%' OUT: '&%C%' INOUT: '&%C%' + INCONV: + IN: |- + %C% = Rf_translateCharUTF8(%I%); + OUTCONV: + OUT: |- + PROTECT(%I% = Rf_mkCharLenCE(%C%, strlen(%C%), CE_UTF8)); REAL: CTYPE: igraph_real_t From b01855dc5909b62843030c299865115ca03738e4 Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Sat, 13 Jan 2024 16:43:03 +0100 Subject: [PATCH 08/13] fix: remove one more --- R/aaa-auto.R | 11 ------- src/cpp11.cpp | 2 -- src/rinterface.c | 80 ------------------------------------------------ 3 files changed, 93 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index d7a5535890..26256c84f7 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -2716,17 +2716,6 @@ to_directed_impl <- function(graph, mode=c("mutual", "arbitrary", "random", "acy res } -read_graph_dimacs_flow_impl <- function(instream, directed=TRUE) { - # Argument checks - directed <- as.logical(directed) - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_read_graph_dimacs_flow, instream, directed) - - res -} - dyad_census_impl <- function(graph) { # Argument checks ensure_igraph(graph) diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 0f1353a391..c9cff0fdcb 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -362,7 +362,6 @@ extern SEXP R_igraph_random_sample(void *, void *, void *); extern SEXP R_igraph_random_spanning_tree(void *, void *); extern SEXP R_igraph_random_walk(void *, void *, void *, void *, void *, void *); extern SEXP R_igraph_read_graph_dimacs(void *, void *); -extern SEXP R_igraph_read_graph_dimacs_flow(void *, void *); extern SEXP R_igraph_read_graph_dl(void *, void *); extern SEXP R_igraph_read_graph_edgelist(void *, void *, void *); extern SEXP R_igraph_read_graph_gml(void *); @@ -823,7 +822,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_random_spanning_tree", (DL_FUNC) &R_igraph_random_spanning_tree, 2}, {"R_igraph_random_walk", (DL_FUNC) &R_igraph_random_walk, 6}, {"R_igraph_read_graph_dimacs", (DL_FUNC) &R_igraph_read_graph_dimacs, 2}, - {"R_igraph_read_graph_dimacs_flow", (DL_FUNC) &R_igraph_read_graph_dimacs_flow, 2}, {"R_igraph_read_graph_dl", (DL_FUNC) &R_igraph_read_graph_dl, 2}, {"R_igraph_read_graph_edgelist", (DL_FUNC) &R_igraph_read_graph_edgelist, 3}, {"R_igraph_read_graph_gml", (DL_FUNC) &R_igraph_read_graph_gml, 1}, diff --git a/src/rinterface.c b/src/rinterface.c index 6384be4fbd..c1b4b744b1 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -8289,86 +8289,6 @@ SEXP R_igraph_to_undirected(SEXP graph, SEXP mode, SEXP edge_attr_comb) { return(r_result); } -/*-------------------------------------------/ -/ igraph_read_graph_dimacs_flow / -/-------------------------------------------*/ -SEXP R_igraph_read_graph_dimacs_flow(SEXP instream, SEXP directed) { - /* Declarations */ - igraph_t c_graph; - FILE* c_instream; - igraph_strvector_t c_problem; - igraph_vector_int_t c_label; - igraph_integer_t c_source; - igraph_integer_t c_target; - igraph_vector_t c_capacity; - igraph_bool_t c_directed; - SEXP graph; - SEXP problem; - SEXP label; - SEXP source; - SEXP target; - SEXP capacity; - - SEXP r_result, r_names; - /* Convert input */ - if (0 != igraph_strvector_init(&c_problem, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_strvector_destroy, &c_problem); - if (0 != igraph_vector_int_init(&c_label, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_label); - c_source=0; - c_target=0; - if (0 != igraph_vector_init(&c_capacity, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_capacity); - IGRAPH_R_CHECK_BOOL(directed); - c_directed = LOGICAL(directed)[0]; - /* Call igraph */ - IGRAPH_R_CHECK(igraph_read_graph_dimacs_flow(&c_graph, c_instream, &c_problem, &c_label, &c_source, &c_target, &c_capacity, c_directed)); - - /* Convert output */ - PROTECT(r_result=NEW_LIST(6)); - PROTECT(r_names=NEW_CHARACTER(6)); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(problem=R_igraph_strvector_to_SEXP(&c_problem)); - igraph_strvector_destroy(&c_problem); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(label=R_igraph_vector_int_to_SEXP(&c_label)); - igraph_vector_int_destroy(&c_label); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(source=NEW_NUMERIC(1)); - REAL(source)[0]=(double) c_source; - PROTECT(target=NEW_NUMERIC(1)); - REAL(target)[0]=(double) c_target; - PROTECT(capacity=R_igraph_vector_to_SEXP(&c_capacity)); - igraph_vector_destroy(&c_capacity); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, graph); - SET_VECTOR_ELT(r_result, 1, problem); - SET_VECTOR_ELT(r_result, 2, label); - SET_VECTOR_ELT(r_result, 3, source); - SET_VECTOR_ELT(r_result, 4, target); - SET_VECTOR_ELT(r_result, 5, capacity); - SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("problem")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("label")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("source")); - SET_STRING_ELT(r_names, 4, Rf_mkChar("target")); - SET_STRING_ELT(r_names, 5, Rf_mkChar("capacity")); - SET_NAMES(r_result, r_names); - UNPROTECT(7); - - UNPROTECT(1); - return(r_result); -} - /*-------------------------------------------/ / igraph_dyad_census / /-------------------------------------------*/ From a3b6f8605ea0ee41c4489b5a1c9ea9f084bbd489 Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Sat, 13 Jan 2024 16:54:28 +0100 Subject: [PATCH 09/13] fix: change print type --- src/rinterface_extra.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 9bd29f0bbf..229c291944 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -73,8 +73,8 @@ enum igraph_versions { void R_check_int_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar integer but received a vector of length %zu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (size_t) Rf_xlength(value)); + igraph_errorf("Expecting a scalar integer but received a vector of length %d.", + __FILE__, __LINE__, IGRAPH_EINVAL, Rf_xlength(value)); } if (((igraph_integer_t) REAL(value)[0]) != REAL(value)[0]) { igraph_errorf("The value %.17g is not representable as an integer.", @@ -85,16 +85,16 @@ void R_check_int_scalar(SEXP value) void R_check_real_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar real but received a vector of length %zu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (size_t) Rf_xlength(value)); + igraph_errorf("Expecting a scalar real but received a vector of length %d.", + __FILE__, __LINE__, IGRAPH_EINVAL, Rf_xlength(value)); } } void R_check_bool_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar logical but received a vector of length %zu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (size_t) Rf_xlength(value)); + igraph_errorf("Expecting a scalar logical but received a vector of length %d.", + __FILE__, __LINE__, IGRAPH_EINVAL, Rf_xlength(value)); } } From b0ad3ef71733a1d6fe4391bff1e27073dd182c2f Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Sat, 13 Jan 2024 17:28:25 +0100 Subject: [PATCH 10/13] fix: use `long int` in error --- src/rinterface_extra.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 229c291944..6847feb0c6 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -73,8 +73,8 @@ enum igraph_versions { void R_check_int_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar integer but received a vector of length %d.", - __FILE__, __LINE__, IGRAPH_EINVAL, Rf_xlength(value)); + igraph_errorf("Expecting a scalar integer but received a vector of length %lu.", + __FILE__, __LINE__, IGRAPH_EINVAL, (long int) Rf_xlength(value)); } if (((igraph_integer_t) REAL(value)[0]) != REAL(value)[0]) { igraph_errorf("The value %.17g is not representable as an integer.", @@ -85,16 +85,16 @@ void R_check_int_scalar(SEXP value) void R_check_real_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar real but received a vector of length %d.", - __FILE__, __LINE__, IGRAPH_EINVAL, Rf_xlength(value)); + igraph_errorf("Expecting a scalar real but received a vector of length %lu.", + __FILE__, __LINE__, IGRAPH_EINVAL, (long int) Rf_xlength(value)); } } void R_check_bool_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar logical but received a vector of length %d.", - __FILE__, __LINE__, IGRAPH_EINVAL, Rf_xlength(value)); + igraph_errorf("Expecting a scalar logical but received a vector of length %lu.", + __FILE__, __LINE__, IGRAPH_EINVAL, (long int) Rf_xlength(value)); } } From 0de89540c2a519c756d1cd4abe0a7516b81f79dc Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Mon, 15 Jan 2024 15:39:45 +0100 Subject: [PATCH 11/13] use `unsigned long` --- src/rinterface_extra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 6847feb0c6..06795f2fd0 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -74,7 +74,7 @@ void R_check_int_scalar(SEXP value) { if (Rf_xlength(value) != 1) { igraph_errorf("Expecting a scalar integer but received a vector of length %lu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (long int) Rf_xlength(value)); + __FILE__, __LINE__, IGRAPH_EINVAL, (unsigned long) Rf_xlength(value)); } if (((igraph_integer_t) REAL(value)[0]) != REAL(value)[0]) { igraph_errorf("The value %.17g is not representable as an integer.", @@ -86,7 +86,7 @@ void R_check_real_scalar(SEXP value) { if (Rf_xlength(value) != 1) { igraph_errorf("Expecting a scalar real but received a vector of length %lu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (long int) Rf_xlength(value)); + __FILE__, __LINE__, IGRAPH_EINVAL, (unsigned long) Rf_xlength(value)); } } @@ -94,7 +94,7 @@ void R_check_bool_scalar(SEXP value) { if (Rf_xlength(value) != 1) { igraph_errorf("Expecting a scalar logical but received a vector of length %lu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (long int) Rf_xlength(value)); + __FILE__, __LINE__, IGRAPH_EINVAL, (unsigned long) Rf_xlength(value)); } } From b98dc71a1d8127fac9f19c604b684a5a63447b82 Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Mon, 15 Jan 2024 16:45:51 +0100 Subject: [PATCH 12/13] using `uintptr_t` --- src/rinterface_extra.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 06795f2fd0..68f3be67e7 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -28,6 +28,7 @@ #include #include +#include #if defined(__SANITIZE_ADDRESS__) # define IGRAPH_SANITIZER_AVAILABLE 1 @@ -73,8 +74,8 @@ enum igraph_versions { void R_check_int_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar integer but received a vector of length %lu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (unsigned long) Rf_xlength(value)); + igraph_errorf("Expecting a scalar integer but received a vector of length %" PRIuPTR ".", + __FILE__, __LINE__, IGRAPH_EINVAL, (uintptr_t) Rf_xlength(value)); } if (((igraph_integer_t) REAL(value)[0]) != REAL(value)[0]) { igraph_errorf("The value %.17g is not representable as an integer.", @@ -85,16 +86,16 @@ void R_check_int_scalar(SEXP value) void R_check_real_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar real but received a vector of length %lu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (unsigned long) Rf_xlength(value)); + igraph_errorf("Expecting a scalar real but received a vector of length %" PRIuPTR ".", + __FILE__, __LINE__, IGRAPH_EINVAL, (uintptr_t) Rf_xlength(value)); } } void R_check_bool_scalar(SEXP value) { if (Rf_xlength(value) != 1) { - igraph_errorf("Expecting a scalar logical but received a vector of length %lu.", - __FILE__, __LINE__, IGRAPH_EINVAL, (unsigned long) Rf_xlength(value)); + igraph_errorf("Expecting a scalar logical but received a vector of length %" PRIuPTR ".", + __FILE__, __LINE__, IGRAPH_EINVAL, (uintptr_t) Rf_xlength(value)); } } From 2da3305200b1f01079460139af47116dcf92fef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 16 Jan 2024 09:15:32 +0100 Subject: [PATCH 13/13] YAGNI --- src/vendor/cigraph/include/igraph_error.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/vendor/cigraph/include/igraph_error.h b/src/vendor/cigraph/include/igraph_error.h index c367d60351..31060dca53 100644 --- a/src/vendor/cigraph/include/igraph_error.h +++ b/src/vendor/cigraph/include/igraph_error.h @@ -794,9 +794,7 @@ IGRAPH_EXPORT int IGRAPH_FINALLY_STACK_SIZE(void); #define IGRAPH_CHECK_CALLBACK(expr, code) \ do { \ igraph_error_t igraph_i_ret = (expr); \ - if (code) { \ - *(code) = igraph_i_ret; \ - } \ + *(code) = igraph_i_ret; \ if (IGRAPH_UNLIKELY(igraph_i_ret != IGRAPH_SUCCESS && igraph_i_ret != IGRAPH_STOP)) { \ IGRAPH_ERROR("", igraph_i_ret); \ } \