From a49bb8b091aeb86c87d3a27efb2a688939253103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 7 Nov 2024 14:53:19 +0100 Subject: [PATCH] chore: Add checks to generated code --- src/rinterface.c | 1474 ++++++++++++---------------------- tools/stimulus/types-RC.yaml | 235 ++---- 2 files changed, 594 insertions(+), 1115 deletions(-) diff --git a/src/rinterface.c b/src/rinterface.c index dc9615cf15..7377d29c28 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -132,13 +132,9 @@ SEXP R_igraph_delete_vertices_idx(SEXP graph, SEXP vertices) { IGRAPH_FINALLY(igraph_destroy, &c_graph); igraph_vector_int_t c_vertices_data; R_SEXP_to_igraph_vs(vertices, &c_graph, &c_vertices, &c_vertices_data); - if (0 != igraph_vector_int_init(&c_idx, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_idx, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_idx); - if (0 != igraph_vector_int_init(&c_invidx, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_invidx, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_invidx); /* Call igraph */ IGRAPH_R_CHECK(igraph_delete_vertices_idx(&c_graph, c_vertices, &c_idx, &c_invidx)); @@ -207,9 +203,7 @@ SEXP R_igraph_get_all_eids_between(SEXP graph, SEXP from, SEXP to, SEXP directed SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_eids, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_eids, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_eids); c_from = (igraph_integer_t) REAL(from)[0]; c_to = (igraph_integer_t) REAL(to)[0]; @@ -275,14 +269,12 @@ SEXP R_igraph_weighted_adjacency(SEXP adjmatrix, SEXP mode, SEXP loops) { /* Convert input */ R_SEXP_to_matrix(adjmatrix, &c_adjmatrix); c_mode = (igraph_adjacency_t) Rf_asInteger(mode); - if (0 != igraph_vector_init(&c_weights, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_weights, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_weights); weights=R_GlobalEnv; /* hack to have a non-NULL value */ c_loops = (igraph_loops_t) Rf_asInteger(loops); /* Call igraph */ - IGRAPH_R_CHECK(igraph_weighted_adjacency(&c_graph, &c_adjmatrix, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_loops)); + IGRAPH_R_CHECK(igraph_weighted_adjacency(&c_graph, &c_adjmatrix, c_mode, &c_weights, c_loops)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -382,7 +374,7 @@ SEXP R_igraph_square_lattice(SEXP dimvector, SEXP nei, SEXP directed, SEXP mutua SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(dimvector, &c_dimvector); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(dimvector, &c_dimvector)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_dimvector); IGRAPH_R_CHECK_INT(nei); c_nei = (igraph_integer_t) REAL(nei)[0]; @@ -422,7 +414,7 @@ SEXP R_igraph_triangular_lattice(SEXP dimvector, SEXP directed, SEXP mutual) { SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(dimvector, &c_dimvector); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(dimvector, &c_dimvector)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_dimvector); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -456,7 +448,7 @@ SEXP R_igraph_symmetric_tree(SEXP branches, SEXP type) { SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(branches, &c_branches); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(branches, &c_branches)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_branches); c_type = (igraph_tree_mode_t) Rf_asInteger(type); /* Call igraph */ @@ -732,7 +724,7 @@ SEXP R_igraph_lcf_vector(SEXP n, SEXP shifts, SEXP repeats) { /* Convert input */ IGRAPH_R_CHECK_INT(n); c_n = (igraph_integer_t) REAL(n)[0]; - R_SEXP_to_vector_int_copy(shifts, &c_shifts); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(shifts, &c_shifts)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_shifts); IGRAPH_R_CHECK_INT(repeats); c_repeats = (igraph_integer_t) REAL(repeats)[0]; @@ -765,9 +757,7 @@ SEXP R_igraph_adjlist(SEXP adjlist, SEXP mode, SEXP duplicate) { SEXP r_result; /* Convert input */ - if (0 != R_SEXP_to_igraph_adjlist(adjlist, &c_adjlist)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_adjlist(adjlist, &c_adjlist)); c_mode = (igraph_neimode_t) Rf_asInteger(mode); IGRAPH_R_CHECK_BOOL(duplicate); c_duplicate = LOGICAL(duplicate)[0]; @@ -802,9 +792,7 @@ SEXP R_igraph_full_bipartite(SEXP n1, SEXP n2, SEXP directed, SEXP mode) { SEXP r_result, r_names; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_types, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); IGRAPH_R_CHECK_INT(n1); c_n1 = (igraph_integer_t) REAL(n1)[0]; @@ -852,11 +840,9 @@ SEXP R_igraph_full_multipartite(SEXP n, SEXP directed, SEXP mode) { SEXP r_result, r_names; /* Convert input */ - if (0 != igraph_vector_int_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_types, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_types); - R_SEXP_to_vector_int_copy(n, &c_n); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(n, &c_n)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_n); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -901,10 +887,10 @@ SEXP R_igraph_realize_degree_sequence(SEXP out_deg, SEXP in_deg, SEXP allowed_ed SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(out_deg, &c_out_deg); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(out_deg, &c_out_deg)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_out_deg); if (!Rf_isNull(in_deg)) { - R_SEXP_to_vector_int_copy(in_deg, &c_in_deg); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(in_deg, &c_in_deg)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_in_deg); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_in_deg, 0)); @@ -944,9 +930,9 @@ SEXP R_igraph_realize_bipartite_degree_sequence(SEXP degrees1, SEXP degrees2, SE SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(degrees1, &c_degrees1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(degrees1, &c_degrees1)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_degrees1); - R_SEXP_to_vector_int_copy(degrees2, &c_degrees2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(degrees2, &c_degrees2)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_degrees2); c_allowed_edge_types = (igraph_edge_type_sw_t) Rf_asInteger(allowed_edge_types); c_method = (igraph_realize_degseq_t) Rf_asInteger(method); @@ -983,7 +969,7 @@ SEXP R_igraph_circulant(SEXP n, SEXP shifts, SEXP directed) { /* Convert input */ IGRAPH_R_CHECK_INT(n); c_n = (igraph_integer_t) REAL(n)[0]; - R_SEXP_to_vector_int_copy(shifts, &c_shifts); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(shifts, &c_shifts)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_shifts); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -1047,9 +1033,7 @@ SEXP R_igraph_turan(SEXP n, SEXP r) { SEXP r_result, r_names; /* Convert input */ - if (0 != igraph_vector_int_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_types, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_types); IGRAPH_R_CHECK_INT(n); c_n = (igraph_integer_t) REAL(n)[0]; @@ -1214,9 +1198,7 @@ SEXP R_igraph_preference_game(SEXP nodes, SEXP types, SEXP type_dist, SEXP fixed IGRAPH_R_CHECK_BOOL(fixed_sizes); c_fixed_sizes = LOGICAL(fixed_sizes)[0]; R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); - if (0 != igraph_vector_int_init(&c_node_type_vec, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_node_type_vec, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_node_type_vec); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -1274,13 +1256,9 @@ SEXP R_igraph_asymmetric_preference_game(SEXP nodes, SEXP out_types, SEXP in_typ c_in_types = (igraph_integer_t) REAL(in_types)[0]; R_SEXP_to_matrix(type_dist_matrix, &c_type_dist_matrix); R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); - if (0 != igraph_vector_int_init(&c_node_type_out_vec, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_node_type_out_vec, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_node_type_out_vec); - if (0 != igraph_vector_int_init(&c_node_type_in_vec, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_node_type_in_vec, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_node_type_in_vec); IGRAPH_R_CHECK_BOOL(loops); c_loops = LOGICAL(loops)[0]; @@ -1626,7 +1604,7 @@ SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed IGRAPH_R_CHECK_INT(n); c_n = (igraph_integer_t) REAL(n)[0]; R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); - R_SEXP_to_vector_int_copy(block_sizes, &c_block_sizes); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(block_sizes, &c_block_sizes)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_block_sizes); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -1702,7 +1680,7 @@ SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP /* Convert input */ IGRAPH_R_CHECK_INT(n); c_n = (igraph_integer_t) REAL(n)[0]; - R_SEXP_to_vector_int_copy(mlist, &c_mlist); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(mlist, &c_mlist)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_mlist); R_igraph_SEXP_to_vector_list(rholist, &c_rholist); R_igraph_SEXP_to_matrixlist(Clist, &c_Clist); @@ -1876,9 +1854,7 @@ SEXP R_igraph_sample_sphere_surface(SEXP dim, SEXP n, SEXP radius, SEXP positive c_radius = REAL(radius)[0]; IGRAPH_R_CHECK_BOOL(positive); c_positive = LOGICAL(positive)[0]; - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_sample_sphere_surface(c_dim, c_n, c_radius, c_positive, &c_res)); @@ -1915,9 +1891,7 @@ SEXP R_igraph_sample_sphere_volume(SEXP dim, SEXP n, SEXP radius, SEXP positive) c_radius = REAL(radius)[0]; IGRAPH_R_CHECK_BOOL(positive); c_positive = LOGICAL(positive)[0]; - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_sample_sphere_volume(c_dim, c_n, c_radius, c_positive, &c_res)); @@ -1947,9 +1921,7 @@ SEXP R_igraph_sample_dirichlet(SEXP n, SEXP alpha) { IGRAPH_R_CHECK_INT(n); c_n = (igraph_integer_t) REAL(n)[0]; R_SEXP_to_vector(alpha, &c_alpha); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_sample_dirichlet(c_n, &c_alpha, &c_res)); @@ -2012,22 +1984,18 @@ SEXP R_igraph_closeness(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP nor SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (0 != igraph_vector_int_init(&c_reachable_count, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_reachable_count, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_reachable_count); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_BOOL(normalized); c_normalized = LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_closeness(&c_graph, &c_res, &c_reachable_count, &c_all_reachable, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized)); + IGRAPH_R_CHECK(igraph_closeness(&c_graph, &c_res, &c_reachable_count, &c_all_reachable, c_vids, c_mode, &c_weights, c_normalized)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -2076,24 +2044,20 @@ SEXP R_igraph_closeness_cutoff(SEXP graph, SEXP vids, SEXP mode, SEXP weights, S SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (0 != igraph_vector_int_init(&c_reachable_count, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_reachable_count, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_reachable_count); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_BOOL(normalized); c_normalized = LOGICAL(normalized)[0]; IGRAPH_R_CHECK_REAL(cutoff); c_cutoff = REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_closeness_cutoff(&c_graph, &c_res, &c_reachable_count, &c_all_reachable, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized, c_cutoff)); + IGRAPH_R_CHECK(igraph_closeness_cutoff(&c_graph, &c_res, &c_reachable_count, &c_all_reachable, c_vids, c_mode, &c_weights, c_normalized, c_cutoff)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -2138,13 +2102,9 @@ SEXP R_igraph_get_shortest_path(SEXP graph, SEXP from, SEXP to, SEXP mode) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); - if (0 != igraph_vector_int_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); c_from = (igraph_integer_t) REAL(from)[0]; c_to = (igraph_integer_t) REAL(to)[0]; @@ -2190,20 +2150,18 @@ SEXP R_igraph_get_shortest_path_bellman_ford(SEXP graph, SEXP from, SEXP to, SEX SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); - if (0 != igraph_vector_int_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); c_from = (igraph_integer_t) REAL(from)[0]; c_to = (igraph_integer_t) REAL(to)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_shortest_path_bellman_ford(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_mode)); + IGRAPH_R_CHECK(igraph_get_shortest_path_bellman_ford(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -2243,20 +2201,18 @@ SEXP R_igraph_get_shortest_path_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP we SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); - if (0 != igraph_vector_int_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); c_from = (igraph_integer_t) REAL(from)[0]; c_to = (igraph_integer_t) REAL(to)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_shortest_path_dijkstra(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_mode)); + IGRAPH_R_CHECK(igraph_get_shortest_path_dijkstra(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -2297,17 +2253,11 @@ SEXP R_igraph_get_all_shortest_paths(SEXP graph, SEXP from, SEXP to, SEXP mode) SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertices); - if (0 != igraph_vector_int_list_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edges); - if (0 != igraph_vector_int_init(&c_nrgeo, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_nrgeo, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_nrgeo); c_from = (igraph_integer_t) REAL(from)[0]; igraph_vector_int_t c_to_data; @@ -2363,25 +2313,19 @@ SEXP R_igraph_get_all_shortest_paths_dijkstra(SEXP graph, SEXP from, SEXP to, SE SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertices); - if (0 != igraph_vector_int_list_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edges); - if (0 != igraph_vector_int_init(&c_nrgeo, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_nrgeo, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_nrgeo); c_from = (igraph_integer_t) REAL(from)[0]; igraph_vector_int_t c_to_data; R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_all_shortest_paths_dijkstra(&c_graph, &c_vertices, &c_edges, &c_nrgeo, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_get_all_shortest_paths_dijkstra(&c_graph, &c_vertices, &c_edges, &c_nrgeo, c_from, c_to, &c_weights, c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -2428,21 +2372,17 @@ SEXP R_igraph_voronoi(SEXP graph, SEXP generators, SEXP weights, SEXP mode, SEXP SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); - if (0 != igraph_vector_init(&c_distances, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_distances, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_distances); R_SEXP_to_vector_int_copy(generators, &c_generators); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_generators); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); c_tiebreaker = (igraph_voronoi_tiebreaker_t) Rf_asInteger(tiebreaker); /* Call igraph */ - IGRAPH_R_CHECK(igraph_voronoi(&c_graph, &c_membership, &c_distances, &c_generators, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, c_tiebreaker)); + IGRAPH_R_CHECK(igraph_voronoi(&c_graph, &c_membership, &c_distances, &c_generators, &c_weights, c_mode, c_tiebreaker)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -2482,9 +2422,7 @@ SEXP R_igraph_get_all_simple_paths(SEXP graph, SEXP from, SEXP to, SEXP cutoff, SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); c_from = (igraph_integer_t) REAL(from)[0]; igraph_vector_int_t c_to_data; @@ -2526,14 +2464,12 @@ SEXP R_igraph_get_k_shortest_paths(SEXP graph, SEXP weights, SEXP k, SEXP from, SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_int_list_init(&c_vertex_paths, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_vertex_paths, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertex_paths); - if (0 != igraph_vector_int_list_init(&c_edge_paths, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_edge_paths, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edge_paths); IGRAPH_R_CHECK_INT(k); c_k = (igraph_integer_t) REAL(k)[0]; @@ -2541,7 +2477,7 @@ SEXP R_igraph_get_k_shortest_paths(SEXP graph, SEXP weights, SEXP k, SEXP from, c_to = (igraph_integer_t) REAL(to)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_k_shortest_paths(&c_graph, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), &c_vertex_paths, &c_edge_paths, c_k, c_from, c_to, c_mode)); + IGRAPH_R_CHECK(igraph_get_k_shortest_paths(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_vertex_paths, &c_edge_paths, c_k, c_from, c_to, c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -2581,20 +2517,16 @@ SEXP R_igraph_get_widest_path(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); - if (0 != igraph_vector_int_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); c_from = (igraph_integer_t) REAL(from)[0]; c_to = (igraph_integer_t) REAL(to)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_widest_path(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_get_widest_path(&c_graph, &c_vertices, &c_edges, c_from, c_to, &c_weights, c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -2638,29 +2570,21 @@ SEXP R_igraph_get_widest_paths(SEXP graph, SEXP from, SEXP to, SEXP weights, SEX SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertices); - if (0 != igraph_vector_int_list_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edges); c_from = (igraph_integer_t) REAL(from)[0]; igraph_vector_int_t c_to_data; R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (0 != igraph_vector_int_init(&c_parents, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_parents, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parents); - if (0 != igraph_vector_int_init(&c_inbound_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_inbound_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_inbound_edges); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_widest_paths(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, &c_parents, &c_inbound_edges)); + IGRAPH_R_CHECK(igraph_get_widest_paths(&c_graph, &c_vertices, &c_edges, c_from, c_to, &c_weights, c_mode, &c_parents, &c_inbound_edges)); /* Convert output */ PROTECT(r_result=NEW_LIST(4)); @@ -2710,18 +2634,16 @@ SEXP R_igraph_widest_path_widths_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP w SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); igraph_vector_int_t c_from_data; R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); igraph_vector_int_t c_to_data; R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_widest_path_widths_dijkstra(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_widest_path_widths_dijkstra(&c_graph, &c_res, c_from, c_to, &c_weights, c_mode)); /* Convert output */ PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); @@ -2753,18 +2675,16 @@ SEXP R_igraph_widest_path_widths_floyd_warshall(SEXP graph, SEXP from, SEXP to, SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); igraph_vector_int_t c_from_data; R_SEXP_to_igraph_vs(from, &c_graph, &c_from, &c_from_data); igraph_vector_int_t c_to_data; R_SEXP_to_igraph_vs(to, &c_graph, &c_to, &c_to_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_widest_path_widths_floyd_warshall(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_widest_path_widths_floyd_warshall(&c_graph, &c_res, c_from, c_to, &c_weights, c_mode)); /* Convert output */ PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); @@ -2794,15 +2714,15 @@ SEXP R_igraph_spanner(SEXP graph, SEXP stretch, SEXP weights) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_spanner, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_spanner, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_spanner); IGRAPH_R_CHECK_REAL(stretch); c_stretch = REAL(stretch)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_spanner(&c_graph, &c_spanner, c_stretch, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)))); + IGRAPH_R_CHECK(igraph_spanner(&c_graph, &c_spanner, c_stretch, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ PROTECT(spanner=R_igraph_vector_int_to_SEXPp1(&c_spanner)); @@ -2830,19 +2750,17 @@ SEXP R_igraph_betweenness_cutoff(SEXP graph, SEXP vids, SEXP directed, SEXP weig SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_REAL(cutoff); c_cutoff = REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_betweenness_cutoff(&c_graph, &c_res, c_vids, c_directed, (Rf_isNull(weights) ? 0 : &c_weights), c_cutoff)); + IGRAPH_R_CHECK(igraph_betweenness_cutoff(&c_graph, &c_res, c_vids, c_directed, &c_weights, c_cutoff)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -2873,9 +2791,7 @@ SEXP R_igraph_betweenness_subset(SEXP graph, SEXP vids, SEXP directed, SEXP sour SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -2885,9 +2801,9 @@ SEXP R_igraph_betweenness_subset(SEXP graph, SEXP vids, SEXP directed, SEXP sour R_SEXP_to_igraph_vs(sources, &c_graph, &c_sources, &c_sources_data); igraph_vector_int_t c_targets_data; R_SEXP_to_igraph_vs(targets, &c_graph, &c_targets, &c_targets_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_betweenness_subset(&c_graph, &c_res, c_vids, c_directed, c_sources, c_targets, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_betweenness_subset(&c_graph, &c_res, c_vids, c_directed, c_sources, c_targets, &c_weights)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -2919,15 +2835,13 @@ SEXP R_igraph_edge_betweenness(SEXP graph, SEXP directed, SEXP weights) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_edge_betweenness(&c_graph, &c_res, c_directed, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_edge_betweenness(&c_graph, &c_res, c_directed, &c_weights)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -2954,17 +2868,15 @@ SEXP R_igraph_edge_betweenness_cutoff(SEXP graph, SEXP directed, SEXP weights, S SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_REAL(cutoff); c_cutoff = REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_edge_betweenness_cutoff(&c_graph, &c_res, c_directed, (Rf_isNull(weights) ? 0 : &c_weights), c_cutoff)); + IGRAPH_R_CHECK(igraph_edge_betweenness_cutoff(&c_graph, &c_res, c_directed, &c_weights, c_cutoff)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -2993,21 +2905,19 @@ SEXP R_igraph_edge_betweenness_subset(SEXP graph, SEXP eids, SEXP directed, SEXP SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_eids_data; - R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data)); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; igraph_vector_int_t c_sources_data; R_SEXP_to_igraph_vs(sources, &c_graph, &c_sources, &c_sources_data); igraph_vector_int_t c_targets_data; R_SEXP_to_igraph_vs(targets, &c_graph, &c_targets, &c_targets_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_edge_betweenness_subset(&c_graph, &c_res, c_eids, c_directed, c_sources, c_targets, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_edge_betweenness_subset(&c_graph, &c_res, c_eids, c_directed, c_sources, c_targets, &c_weights)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -3042,20 +2952,18 @@ SEXP R_igraph_harmonic_centrality_cutoff(SEXP graph, SEXP vids, SEXP mode, SEXP SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_BOOL(normalized); c_normalized = LOGICAL(normalized)[0]; IGRAPH_R_CHECK_REAL(cutoff); c_cutoff = REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_harmonic_centrality_cutoff(&c_graph, &c_res, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized, c_cutoff)); + IGRAPH_R_CHECK(igraph_harmonic_centrality_cutoff(&c_graph, &c_res, c_vids, c_mode, &c_weights, c_normalized, c_cutoff)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -3092,9 +3000,7 @@ SEXP R_igraph_personalized_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP direc /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); c_algo = (igraph_pagerank_algo_t) Rf_asInteger(algo); - if (0 != igraph_vector_init(&c_vector, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_vector, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -3105,15 +3011,17 @@ SEXP R_igraph_personalized_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP direc if (!Rf_isNull(personalized)) { R_SEXP_to_vector(personalized, &c_personalized); } - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { R_SEXP_to_igraph_arpack_options(options, &c_options1); c_options = &c_options1; } else { - c_options = 0; + c_options = NULL; } /* Call igraph */ - IGRAPH_R_CHECK(igraph_personalized_pagerank(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, (Rf_isNull(personalized) ? 0 : &c_personalized), (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_options)); + IGRAPH_R_CHECK(igraph_personalized_pagerank(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, (Rf_isNull(personalized) ? 0 : &c_personalized), (Rf_isNull(weights) ? 0 : &c_weights), c_options)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -3166,9 +3074,7 @@ SEXP R_igraph_personalized_pagerank_vs(SEXP graph, SEXP algo, SEXP vids, SEXP di /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); c_algo = (igraph_pagerank_algo_t) Rf_asInteger(algo); - if (0 != igraph_vector_init(&c_vector, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_vector, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -3178,15 +3084,17 @@ SEXP R_igraph_personalized_pagerank_vs(SEXP graph, SEXP algo, SEXP vids, SEXP di c_damping = REAL(damping)[0]; igraph_vector_int_t c_reset_vids_data; R_SEXP_to_igraph_vs(reset_vids, &c_graph, &c_reset_vids, &c_reset_vids_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { R_SEXP_to_igraph_arpack_options(options, &c_options1); c_options = &c_options1; } else { - c_options = 0; + c_options = NULL; } /* Call igraph */ - IGRAPH_R_CHECK(igraph_personalized_pagerank_vs(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, c_reset_vids, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_options)); + IGRAPH_R_CHECK(igraph_personalized_pagerank_vs(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, c_reset_vids, (Rf_isNull(weights) ? 0 : &c_weights), c_options)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -3266,7 +3174,7 @@ SEXP R_igraph_subgraph_from_edges(SEXP graph, SEXP eids, SEXP delete_vertices) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); igraph_vector_int_t c_eids_data; - R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data)); IGRAPH_R_CHECK_BOOL(delete_vertices); c_delete_vertices = LOGICAL(delete_vertices)[0]; /* Call igraph */ @@ -3298,7 +3206,7 @@ SEXP R_igraph_reverse_edges(SEXP graph, SEXP eids) { R_SEXP_to_igraph_copy(graph, &c_graph); IGRAPH_FINALLY(igraph_destroy, &c_graph); igraph_vector_int_t c_eids_data; - R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data)); /* Call igraph */ IGRAPH_R_CHECK(igraph_reverse_edges(&c_graph, c_eids)); @@ -3331,13 +3239,13 @@ SEXP R_igraph_average_path_length_dijkstra(SEXP graph, SEXP weights, SEXP direct SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; IGRAPH_R_CHECK_BOOL(unconn); c_unconn = LOGICAL(unconn)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_average_path_length_dijkstra(&c_graph, &c_res, &c_unconn_pairs, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_unconn)); + IGRAPH_R_CHECK(igraph_average_path_length_dijkstra(&c_graph, &c_res, &c_unconn_pairs, &c_weights, c_directed, c_unconn)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -3372,9 +3280,7 @@ SEXP R_igraph_path_length_hist(SEXP graph, SEXP directed) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -3475,9 +3381,7 @@ SEXP R_igraph_transitivity_local_undirected(SEXP graph, SEXP vids, SEXP mode) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -3538,16 +3442,14 @@ SEXP R_igraph_transitivity_barrat(SEXP graph, SEXP vids, SEXP weights, SEXP mode SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_transitivity_mode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_transitivity_barrat(&c_graph, &c_res, c_vids, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_transitivity_barrat(&c_graph, &c_res, c_vids, &c_weights, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -3577,12 +3479,10 @@ SEXP R_igraph_ecc(SEXP graph, SEXP eids, SEXP k, SEXP offset, SEXP normalize) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_eids_data; - R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data)); IGRAPH_R_CHECK_INT(k); c_k = (igraph_integer_t) REAL(k)[0]; IGRAPH_R_CHECK_BOOL(offset); @@ -3736,14 +3636,12 @@ SEXP R_igraph_feedback_arc_set(SEXP graph, SEXP weights, SEXP algo) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_result, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_result, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_result); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_algo = (igraph_fas_algorithm_t) Rf_asInteger(algo); /* Call igraph */ - IGRAPH_R_CHECK(igraph_feedback_arc_set(&c_graph, &c_result, (Rf_isNull(weights) ? 0 : &c_weights), c_algo)); + IGRAPH_R_CHECK(igraph_feedback_arc_set(&c_graph, &c_result, &c_weights, c_algo)); /* Convert output */ PROTECT(result=R_igraph_vector_int_to_SEXPp1(&c_result)); @@ -3768,12 +3666,10 @@ SEXP R_igraph_is_loop(SEXP graph, SEXP es) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); igraph_vector_int_t c_es_data; - R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data)); /* Call igraph */ IGRAPH_R_CHECK(igraph_is_loop(&c_graph, &c_res, c_es)); @@ -3874,12 +3770,10 @@ SEXP R_igraph_is_multiple(SEXP graph, SEXP es) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); igraph_vector_int_t c_es_data; - R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data)); /* Call igraph */ IGRAPH_R_CHECK(igraph_is_multiple(&c_graph, &c_res, c_es)); @@ -3981,12 +3875,10 @@ SEXP R_igraph_count_multiple(SEXP graph, SEXP es) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); igraph_vector_int_t c_es_data; - R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data)); /* Call igraph */ IGRAPH_R_CHECK(igraph_count_multiple(&c_graph, &c_res, c_es)); @@ -4044,18 +3936,16 @@ SEXP R_igraph_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_vector, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_vector, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; IGRAPH_R_CHECK_BOOL(scale); c_scale = LOGICAL(scale)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); R_SEXP_to_igraph_arpack_options(options, &c_options); /* Call igraph */ - IGRAPH_R_CHECK(igraph_eigenvector_centrality(&c_graph, &c_vector, &c_value, c_directed, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); + IGRAPH_R_CHECK(igraph_eigenvector_centrality(&c_graph, &c_vector, &c_value, c_directed, c_scale, &c_weights, &c_options)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -4098,20 +3988,16 @@ SEXP R_igraph_hub_and_authority_scores(SEXP graph, SEXP scale, SEXP weights, SEX SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_hub, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_hub, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_hub); - if (0 != igraph_vector_init(&c_authority, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_authority, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_authority); IGRAPH_R_CHECK_BOOL(scale); c_scale = LOGICAL(scale)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); R_SEXP_to_igraph_arpack_options(options, &c_options); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hub_and_authority_scores(&c_graph, &c_hub, &c_authority, &c_value, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); + IGRAPH_R_CHECK(igraph_hub_and_authority_scores(&c_graph, &c_hub, &c_authority, &c_value, c_scale, &c_weights, &c_options)); /* Convert output */ PROTECT(r_result=NEW_LIST(4)); @@ -4157,11 +4043,9 @@ SEXP R_igraph_unfold_tree(SEXP graph, SEXP mode, SEXP roots) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); c_mode = (igraph_neimode_t) Rf_asInteger(mode); - R_SEXP_to_vector_int_copy(roots, &c_roots); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(roots, &c_roots)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_roots); - if (0 != igraph_vector_int_init(&c_vertex_index, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_index, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_index); /* Call igraph */ IGRAPH_R_CHECK(igraph_unfold_tree(&c_graph, &c_tree, c_mode, &c_roots, &c_vertex_index)); @@ -4203,12 +4087,10 @@ SEXP R_igraph_is_mutual(SEXP graph, SEXP es, SEXP loops) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); igraph_vector_int_t c_es_data; - R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data)); IGRAPH_R_CHECK_BOOL(loops); c_loops = LOGICAL(loops)[0]; /* Call igraph */ @@ -4267,13 +4149,9 @@ SEXP R_igraph_maximum_cardinality_search(SEXP graph) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_alpha, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_alpha, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_alpha); - if (0 != igraph_vector_int_init(&c_alpham1, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_alpham1, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_alpham1); /* Call igraph */ IGRAPH_R_CHECK(igraph_maximum_cardinality_search(&c_graph, &c_alpha, &c_alpham1)); @@ -4320,17 +4198,13 @@ SEXP R_igraph_avg_nearest_neighbor_degree(SEXP graph, SEXP vids, SEXP mode, SEXP R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_mode = (igraph_neimode_t) Rf_asInteger(mode); c_neighbor_degree_mode = (igraph_neimode_t) Rf_asInteger(neighbor_degree_mode); - if (0 != igraph_vector_init(&c_knn, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_knn, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_knn); - if (0 != igraph_vector_init(&c_knnk, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_knnk, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_knnk); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_avg_nearest_neighbor_degree(&c_graph, c_vids, c_mode, c_neighbor_degree_mode, &c_knn, &c_knnk, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_avg_nearest_neighbor_degree(&c_graph, c_vids, c_mode, c_neighbor_degree_mode, &c_knn, &c_knnk, &c_weights)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -4370,17 +4244,15 @@ SEXP R_igraph_degree_correlation_vector(SEXP graph, SEXP weights, SEXP from_mode SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_init(&c_knnk, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_vector_init(&c_knnk, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_knnk); c_from_mode = (igraph_neimode_t) Rf_asInteger(from_mode); c_to_mode = (igraph_neimode_t) Rf_asInteger(to_mode); IGRAPH_R_CHECK_BOOL(directed_neighbors); c_directed_neighbors = LOGICAL(directed_neighbors)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_degree_correlation_vector(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_knnk, c_from_mode, c_to_mode, c_directed_neighbors)); + IGRAPH_R_CHECK(igraph_degree_correlation_vector(&c_graph, &c_weights, &c_knnk, c_from_mode, c_to_mode, c_directed_neighbors)); /* Convert output */ PROTECT(knnk=R_igraph_vector_to_SEXP(&c_knnk)); @@ -4408,18 +4280,16 @@ SEXP R_igraph_strength(SEXP graph, SEXP vids, SEXP mode, SEXP loops, SEXP weight SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_mode = (igraph_neimode_t) Rf_asInteger(mode); IGRAPH_R_CHECK_BOOL(loops); c_loops = LOGICAL(loops)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_strength(&c_graph, &c_res, c_vids, c_mode, c_loops, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_strength(&c_graph, &c_res, c_vids, c_mode, c_loops, &c_weights)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -4480,9 +4350,7 @@ SEXP R_igraph_centralization_degree(SEXP graph, SEXP mode, SEXP loops, SEXP norm SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); c_mode = (igraph_neimode_t) Rf_asInteger(mode); IGRAPH_R_CHECK_BOOL(loops); @@ -4567,9 +4435,7 @@ SEXP R_igraph_centralization_betweenness(SEXP graph, SEXP directed, SEXP normali SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -4651,9 +4517,7 @@ SEXP R_igraph_centralization_closeness(SEXP graph, SEXP mode, SEXP normalized) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); c_mode = (igraph_neimode_t) Rf_asInteger(mode); IGRAPH_R_CHECK_BOOL(normalized); @@ -4737,9 +4601,7 @@ SEXP R_igraph_centralization_eigenvector_centrality(SEXP graph, SEXP directed, S SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_vector, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_vector, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; @@ -4929,17 +4791,15 @@ SEXP R_igraph_joint_degree_matrix(SEXP graph, SEXP weights, SEXP max_out_degree, SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_matrix_init(&c_jdm, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_matrix_init(&c_jdm, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_jdm); IGRAPH_R_CHECK_INT(max_out_degree); c_max_out_degree = (igraph_integer_t) REAL(max_out_degree)[0]; IGRAPH_R_CHECK_INT(max_in_degree); c_max_in_degree = (igraph_integer_t) REAL(max_in_degree)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_joint_degree_matrix(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_jdm, c_max_out_degree, c_max_in_degree)); + IGRAPH_R_CHECK(igraph_joint_degree_matrix(&c_graph, &c_weights, &c_jdm, c_max_out_degree, c_max_in_degree)); /* Convert output */ PROTECT(jdm=R_igraph_matrix_to_SEXP(&c_jdm)); @@ -4970,10 +4830,8 @@ SEXP R_igraph_joint_degree_distribution(SEXP graph, SEXP weights, SEXP from_mode SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_matrix_init(&c_p, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_matrix_init(&c_p, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_p); c_from_mode = (igraph_neimode_t) Rf_asInteger(from_mode); c_to_mode = (igraph_neimode_t) Rf_asInteger(to_mode); @@ -4986,7 +4844,7 @@ SEXP R_igraph_joint_degree_distribution(SEXP graph, SEXP weights, SEXP from_mode IGRAPH_R_CHECK_INT(max_to_degree); c_max_to_degree = (igraph_integer_t) REAL(max_to_degree)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_joint_degree_distribution(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_p, c_from_mode, c_to_mode, c_directed_neighbors, c_normalized, c_max_from_degree, c_max_to_degree)); + IGRAPH_R_CHECK(igraph_joint_degree_distribution(&c_graph, &c_weights, &c_p, c_from_mode, c_to_mode, c_directed_neighbors, c_normalized, c_max_from_degree, c_max_to_degree)); /* Convert output */ PROTECT(p=R_igraph_matrix_to_SEXP(&c_p)); @@ -5015,10 +4873,8 @@ SEXP R_igraph_joint_type_distribution(SEXP graph, SEXP weights, SEXP from_types, SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_matrix_init(&c_p, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_matrix_init(&c_p, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_p); R_SEXP_to_vector_int_copy(from_types, &c_from_types); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_from_types); @@ -5029,7 +4885,7 @@ SEXP R_igraph_joint_type_distribution(SEXP graph, SEXP weights, SEXP from_types, IGRAPH_R_CHECK_BOOL(normalized); c_normalized = LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_joint_type_distribution(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_p, &c_from_types, &c_to_types, c_directed, c_normalized)); + IGRAPH_R_CHECK(igraph_joint_type_distribution(&c_graph, &c_weights, &c_p, &c_from_types, &c_to_types, c_directed, c_normalized)); /* Convert output */ PROTECT(p=R_igraph_matrix_to_SEXP(&c_p)); @@ -5094,16 +4950,14 @@ SEXP R_igraph_eccentricity_dijkstra(SEXP graph, SEXP weights, SEXP vids, SEXP mo SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_eccentricity_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_vids, c_mode)); + IGRAPH_R_CHECK(igraph_eccentricity_dijkstra(&c_graph, &c_weights, &c_res, c_vids, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -5131,14 +4985,12 @@ SEXP R_igraph_graph_center_dijkstra(SEXP graph, SEXP weights, SEXP mode) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_graph_center_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_mode)); + IGRAPH_R_CHECK(igraph_graph_center_dijkstra(&c_graph, &c_weights, &c_res, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); @@ -5164,10 +5016,10 @@ SEXP R_igraph_radius_dijkstra(SEXP graph, SEXP weights, SEXP mode) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_radius_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_radius, c_mode)); + IGRAPH_R_CHECK(igraph_radius_dijkstra(&c_graph, &c_weights, &c_radius, c_mode)); /* Convert output */ PROTECT(radius=NEW_NUMERIC(1)); @@ -5249,7 +5101,7 @@ SEXP R_igraph_pseudo_diameter_dijkstra(SEXP graph, SEXP weights, SEXP start_vid, SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_start_vid = (igraph_integer_t) REAL(start_vid)[0]; c_from=0; c_to=0; @@ -5258,7 +5110,7 @@ SEXP R_igraph_pseudo_diameter_dijkstra(SEXP graph, SEXP weights, SEXP start_vid, IGRAPH_R_CHECK_BOOL(unconnected); c_unconnected = LOGICAL(unconnected)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_pseudo_diameter_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_diameter, c_start_vid, &c_from, &c_to, c_directed, c_unconnected)); + IGRAPH_R_CHECK(igraph_pseudo_diameter_dijkstra(&c_graph, &c_weights, &c_diameter, c_start_vid, &c_from, &c_to, c_directed, c_unconnected)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -5296,15 +5148,13 @@ SEXP R_igraph_diversity(SEXP graph, SEXP weights, SEXP vids) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); /* Call igraph */ - IGRAPH_R_CHECK(igraph_diversity(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_vids)); + IGRAPH_R_CHECK(igraph_diversity(&c_graph, &c_weights, &c_res, c_vids)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -5337,14 +5187,10 @@ SEXP R_igraph_random_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_int_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); - if (0 != igraph_vector_int_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); c_start = (igraph_integer_t) REAL(start)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); @@ -5352,7 +5198,7 @@ SEXP R_igraph_random_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP c_steps = (igraph_integer_t) REAL(steps)[0]; c_stuck = (igraph_random_walk_stuck_t) Rf_asInteger(stuck); /* Call igraph */ - IGRAPH_R_CHECK(igraph_random_walk(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_vertices, &c_edges, c_start, c_mode, c_steps, c_stuck)); + IGRAPH_R_CHECK(igraph_random_walk(&c_graph, &c_weights, &c_vertices, &c_edges, c_start, c_mode, c_steps, c_stuck)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -5388,11 +5234,11 @@ SEXP R_igraph_global_efficiency(SEXP graph, SEXP weights, SEXP directed) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_global_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed)); + IGRAPH_R_CHECK(igraph_global_efficiency(&c_graph, &c_res, &c_weights, c_directed)); /* Convert output */ PROTECT(res=NEW_NUMERIC(1)); @@ -5419,18 +5265,16 @@ SEXP R_igraph_local_efficiency(SEXP graph, SEXP vids, SEXP weights, SEXP directe SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_efficiency(&c_graph, &c_res, c_vids, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_mode)); + IGRAPH_R_CHECK(igraph_local_efficiency(&c_graph, &c_res, c_vids, &c_weights, c_directed, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -5459,12 +5303,12 @@ SEXP R_igraph_average_local_efficiency(SEXP graph, SEXP weights, SEXP directed, SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_average_local_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_mode)); + IGRAPH_R_CHECK(igraph_average_local_efficiency(&c_graph, &c_res, &c_weights, c_directed, c_mode)); /* Convert output */ PROTECT(res=NEW_NUMERIC(1)); @@ -5539,9 +5383,7 @@ SEXP R_igraph_trussness(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_trussness, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_trussness, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_trussness); /* Call igraph */ IGRAPH_R_CHECK(igraph_trussness(&c_graph, &c_trussness)); @@ -5569,10 +5411,10 @@ SEXP R_igraph_is_graphical(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types) { SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(out_deg, &c_out_deg); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(out_deg, &c_out_deg)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_out_deg); if (!Rf_isNull(in_deg)) { - R_SEXP_to_vector_int_copy(in_deg, &c_in_deg); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(in_deg, &c_in_deg)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_in_deg); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_in_deg, 0)); @@ -5615,17 +5457,11 @@ SEXP R_igraph_bfs_simple(SEXP graph, SEXP root, SEXP mode) { R_SEXP_to_igraph(graph, &c_graph); c_root = (igraph_integer_t) REAL(root)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (0 != igraph_vector_int_init(&c_order, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_order, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_order); - if (0 != igraph_vector_int_init(&c_layers, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_layers, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_layers); - if (0 != igraph_vector_int_init(&c_parents, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_parents, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parents); /* Call igraph */ IGRAPH_R_CHECK(igraph_bfs_simple(&c_graph, c_root, c_mode, &c_order, &c_layers, &c_parents)); @@ -5674,13 +5510,13 @@ SEXP R_igraph_bipartite_projection_size(SEXP graph, SEXP types) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + R_SEXP_to_vector_bool(types, &c_types); c_vcount1=0; c_ecount1=0; c_vcount2=0; c_ecount2=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_bipartite_projection_size(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_vcount1, &c_ecount1, &c_vcount2, &c_ecount2)); + IGRAPH_R_CHECK(igraph_bipartite_projection_size(&c_graph, &c_types, &c_vcount1, &c_ecount1, &c_vcount2, &c_ecount2)); /* Convert output */ PROTECT(r_result=NEW_LIST(4)); @@ -5721,13 +5557,13 @@ SEXP R_igraph_create_bipartite(SEXP types, SEXP edges, SEXP directed) { SEXP r_result; /* Convert input */ - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - R_SEXP_to_vector_int_copy(edges, &c_edges); + R_SEXP_to_vector_bool(types, &c_types); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edges, &c_edges)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_create_bipartite(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_edges, c_directed)); + IGRAPH_R_CHECK(igraph_create_bipartite(&c_graph, &c_types, &c_edges, c_directed)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -5758,9 +5594,7 @@ SEXP R_igraph_biadjacency(SEXP incidence, SEXP directed, SEXP mode, SEXP multipl SEXP r_result, r_names; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_types, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); R_SEXP_to_matrix(incidence, &c_incidence); IGRAPH_R_CHECK_BOOL(directed); @@ -5809,21 +5643,15 @@ SEXP R_igraph_get_biadjacency(SEXP graph, SEXP types) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector_bool(types, &c_types); + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - if (0 != igraph_vector_int_init(&c_row_ids, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_row_ids, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_row_ids); - if (0 != igraph_vector_int_init(&c_col_ids, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_col_ids, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_col_ids); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_biadjacency(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_res, &c_row_ids, &c_col_ids)); + IGRAPH_R_CHECK(igraph_get_biadjacency(&c_graph, &c_types, &c_res, &c_row_ids, &c_col_ids)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -5864,9 +5692,7 @@ SEXP R_igraph_is_bipartite(SEXP graph) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_type, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_type, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_type); /* Call igraph */ IGRAPH_R_CHECK(igraph_is_bipartite(&c_graph, &c_res, &c_type)); @@ -5907,9 +5733,7 @@ SEXP R_igraph_bipartite_game_gnp(SEXP n1, SEXP n2, SEXP p, SEXP directed, SEXP m SEXP r_result, r_names; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_types, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); IGRAPH_R_CHECK_INT(n1); c_n1 = (igraph_integer_t) REAL(n1)[0]; @@ -5961,9 +5785,7 @@ SEXP R_igraph_bipartite_game_gnm(SEXP n1, SEXP n2, SEXP m, SEXP directed, SEXP m SEXP r_result, r_names; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&c_types, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); IGRAPH_R_CHECK_INT(n1); c_n1 = (igraph_integer_t) REAL(n1)[0]; @@ -6013,15 +5835,13 @@ SEXP R_igraph_get_laplacian(SEXP graph, SEXP mode, SEXP normalization, SEXP weig SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); c_mode = (igraph_neimode_t) Rf_asInteger(mode); c_normalization = (igraph_laplacian_normalization_t) Rf_asInteger(normalization); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_laplacian(&c_graph, &c_res, c_mode, c_normalization, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_get_laplacian(&c_graph, &c_res, c_mode, c_normalization, &c_weights)); /* Convert output */ PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); @@ -6048,15 +5868,13 @@ SEXP R_igraph_get_laplacian_sparse(SEXP graph, SEXP mode, SEXP normalization, SE SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_sparsemat_init(&c_sparseres, 0, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_sparsemat_init(&c_sparseres, 0, 0, 0)); IGRAPH_FINALLY(igraph_sparsemat_destroy, &c_sparseres); c_mode = (igraph_neimode_t) Rf_asInteger(mode); c_normalization = (igraph_laplacian_normalization_t) Rf_asInteger(normalization); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_laplacian_sparse(&c_graph, &c_sparseres, c_mode, c_normalization, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_get_laplacian_sparse(&c_graph, &c_sparseres, c_mode, c_normalization, &c_weights)); /* Convert output */ PROTECT(sparseres=R_igraph_sparsemat_to_SEXP(&c_sparseres)); @@ -6085,13 +5903,9 @@ SEXP R_igraph_connected_components(SEXP graph, SEXP mode) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); - if (0 != igraph_vector_int_init(&c_csize, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_csize, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_csize); c_no=0; c_mode = (igraph_connectedness_t) Rf_asInteger(mode); @@ -6160,9 +5974,7 @@ SEXP R_igraph_articulation_points(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_articulation_points(&c_graph, &c_res)); @@ -6198,21 +6010,13 @@ SEXP R_igraph_biconnected_components(SEXP graph) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); c_no=0; - if (0 != igraph_vector_int_list_init(&c_tree_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_tree_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_tree_edges); - if (0 != igraph_vector_int_list_init(&c_component_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_component_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_component_edges); - if (0 != igraph_vector_int_list_init(&c_components, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_components, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_components); - if (0 != igraph_vector_int_init(&c_articulation_points, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_articulation_points, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_articulation_points); /* Call igraph */ IGRAPH_R_CHECK(igraph_biconnected_components(&c_graph, &c_no, &c_tree_edges, &c_component_edges, &c_components, &c_articulation_points)); @@ -6263,9 +6067,7 @@ SEXP R_igraph_bridges(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_bridges(&c_graph, &c_res)); @@ -6317,9 +6119,7 @@ SEXP R_igraph_count_reachable(SEXP graph, SEXP mode) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_counts, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_counts, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_counts); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ @@ -6381,9 +6181,7 @@ SEXP R_igraph_cliques(SEXP graph, SEXP min_size, SEXP max_size) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); IGRAPH_R_CHECK_INT(min_size); c_min_size = (igraph_integer_t) REAL(min_size)[0]; @@ -6416,9 +6214,7 @@ SEXP R_igraph_clique_size_hist(SEXP graph, SEXP min_size, SEXP max_size) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_hist, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_hist, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); IGRAPH_R_CHECK_INT(min_size); c_min_size = (igraph_integer_t) REAL(min_size)[0]; @@ -6449,9 +6245,7 @@ SEXP R_igraph_largest_cliques(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_largest_cliques(&c_graph, &c_res)); @@ -6480,9 +6274,7 @@ SEXP R_igraph_maximal_cliques_hist(SEXP graph, SEXP min_size, SEXP max_size) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_hist, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_hist, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); IGRAPH_R_CHECK_INT(min_size); c_min_size = (igraph_integer_t) REAL(min_size)[0]; @@ -6542,10 +6334,8 @@ SEXP R_igraph_weighted_cliques(SEXP graph, SEXP vertex_weights, SEXP min_weight, SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } - if (0 != igraph_vector_int_list_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(vertex_weights, &c_vertex_weights); + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); IGRAPH_R_CHECK_REAL(min_weight); c_min_weight = REAL(min_weight)[0]; @@ -6554,7 +6344,7 @@ SEXP R_igraph_weighted_cliques(SEXP graph, SEXP vertex_weights, SEXP min_weight, IGRAPH_R_CHECK_BOOL(maximal); c_maximal = LOGICAL(maximal)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_weighted_cliques(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res, c_min_weight, c_max_weight, c_maximal)); + IGRAPH_R_CHECK(igraph_weighted_cliques(&c_graph, &c_vertex_weights, &c_res, c_min_weight, c_max_weight, c_maximal)); /* Convert output */ PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); @@ -6579,13 +6369,11 @@ SEXP R_igraph_largest_weighted_cliques(SEXP graph, SEXP vertex_weights) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } - if (0 != igraph_vector_int_list_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(vertex_weights, &c_vertex_weights); + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_largest_weighted_cliques(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); + IGRAPH_R_CHECK(igraph_largest_weighted_cliques(&c_graph, &c_vertex_weights, &c_res)); /* Convert output */ PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); @@ -6610,9 +6398,9 @@ SEXP R_igraph_weighted_clique_number(SEXP graph, SEXP vertex_weights) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + R_SEXP_to_vector(vertex_weights, &c_vertex_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_weighted_clique_number(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); + IGRAPH_R_CHECK(igraph_weighted_clique_number(&c_graph, &c_vertex_weights, &c_res)); /* Convert output */ PROTECT(res=NEW_NUMERIC(1)); @@ -6664,9 +6452,7 @@ SEXP R_igraph_layout_random(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_layout_random(&c_graph, &c_res)); @@ -6694,9 +6480,7 @@ SEXP R_igraph_layout_circle(SEXP graph, SEXP order) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); igraph_vector_int_t c_order_data; R_SEXP_to_igraph_vs(order, &c_graph, &c_order, &c_order_data); @@ -6729,9 +6513,7 @@ SEXP R_igraph_layout_star(SEXP graph, SEXP center, SEXP order) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); c_center = (igraph_integer_t) REAL(center)[0]; if (!Rf_isNull(order)) { @@ -6769,9 +6551,7 @@ SEXP R_igraph_layout_grid(SEXP graph, SEXP width) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_INT(width); c_width = (igraph_integer_t) REAL(width)[0]; @@ -6802,9 +6582,7 @@ SEXP R_igraph_layout_grid_3d(SEXP graph, SEXP width, SEXP height) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_INT(width); c_width = (igraph_integer_t) REAL(width)[0]; @@ -6838,9 +6616,7 @@ SEXP R_igraph_roots_for_tree_layout(SEXP graph, SEXP mode, SEXP heuristic) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (0 != igraph_vector_int_init(&c_roots, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_roots, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_roots); c_heuristic = (igraph_root_choice_t) Rf_asInteger(heuristic); /* Call igraph */ @@ -6868,9 +6644,7 @@ SEXP R_igraph_layout_random_3d(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_layout_random_3d(&c_graph, &c_res)); @@ -6897,9 +6671,7 @@ SEXP R_igraph_layout_sphere(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_layout_sphere(&c_graph, &c_res)); @@ -6928,16 +6700,16 @@ SEXP R_igraph_layout_drl(SEXP graph, SEXP res, SEXP use_seed, SEXP options, SEXP SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_copy(res, &c_res)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_BOOL(use_seed); c_use_seed = LOGICAL(use_seed)[0]; R_SEXP_to_igraph_layout_drl_options(options, &c_options); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_drl(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)))); + IGRAPH_R_CHECK(igraph_layout_drl(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); @@ -6963,16 +6735,16 @@ SEXP R_igraph_layout_drl_3d(SEXP graph, SEXP res, SEXP use_seed, SEXP options, S SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_copy(res, &c_res)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_BOOL(use_seed); c_use_seed = LOGICAL(use_seed)[0]; R_SEXP_to_igraph_layout_drl_options(options, &c_options); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_drl_3d(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)))); + IGRAPH_R_CHECK(igraph_layout_drl_3d(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); @@ -7005,13 +6777,9 @@ SEXP R_igraph_layout_sugiyama(SEXP graph, SEXP layers, SEXP hgap, SEXP vgap, SEX SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - if (0 != igraph_vector_int_init(&c_extd_to_orig_eids, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_extd_to_orig_eids, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_extd_to_orig_eids); if (!Rf_isNull(layers)) { R_SEXP_to_vector_int_copy(layers, &c_layers); @@ -7026,9 +6794,9 @@ SEXP R_igraph_layout_sugiyama(SEXP graph, SEXP layers, SEXP hgap, SEXP vgap, SEX c_vgap = REAL(vgap)[0]; IGRAPH_R_CHECK_INT(maxiter); c_maxiter = (igraph_integer_t) REAL(maxiter)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_sugiyama(&c_graph, &c_res, &c_extd_graph, &c_extd_to_orig_eids, (Rf_isNull(layers) ? 0 : &c_layers), c_hgap, c_vgap, c_maxiter, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_layout_sugiyama(&c_graph, &c_res, &c_extd_graph, &c_extd_to_orig_eids, (Rf_isNull(layers) ? 0 : &c_layers), c_hgap, c_vgap, c_maxiter, &c_weights)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -7072,9 +6840,7 @@ SEXP R_igraph_layout_mds(SEXP graph, SEXP dist, SEXP dim) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); if (!Rf_isNull(dist)) { R_SEXP_to_matrix(dist, &c_dist); @@ -7110,10 +6876,8 @@ SEXP R_igraph_layout_bipartite(SEXP graph, SEXP types, SEXP hgap, SEXP vgap, SEX SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector_bool(types, &c_types); + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_REAL(hgap); c_hgap = REAL(hgap)[0]; @@ -7122,7 +6886,7 @@ SEXP R_igraph_layout_bipartite(SEXP graph, SEXP types, SEXP hgap, SEXP vgap, SEX IGRAPH_R_CHECK_INT(maxiter); c_maxiter = (igraph_integer_t) REAL(maxiter)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_bipartite(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_res, c_hgap, c_vgap, c_maxiter)); + IGRAPH_R_CHECK(igraph_layout_bipartite(&c_graph, &c_types, &c_res, c_hgap, c_vgap, c_maxiter)); /* Convert output */ PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); @@ -7150,9 +6914,7 @@ SEXP R_igraph_layout_gem(SEXP graph, SEXP res, SEXP use_seed, SEXP maxiter, SEXP SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_copy(res, &c_res)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_BOOL(use_seed); c_use_seed = LOGICAL(use_seed)[0]; @@ -7197,9 +6959,7 @@ SEXP R_igraph_layout_davidson_harel(SEXP graph, SEXP res, SEXP use_seed, SEXP ma SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_copy(res, &c_res)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_BOOL(use_seed); c_use_seed = LOGICAL(use_seed)[0]; @@ -7248,9 +7008,7 @@ SEXP R_igraph_layout_umap(SEXP graph, SEXP res, SEXP use_seed, SEXP distances, S SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_copy(res, &c_res)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_BOOL(use_seed); c_use_seed = LOGICAL(use_seed)[0]; @@ -7292,9 +7050,7 @@ SEXP R_igraph_layout_umap_3d(SEXP graph, SEXP res, SEXP use_seed, SEXP distances SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_copy(res, &c_res)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_BOOL(use_seed); c_use_seed = LOGICAL(use_seed)[0]; @@ -7333,9 +7089,7 @@ SEXP R_igraph_layout_umap_compute_weights(SEXP graph, SEXP distances, SEXP weigh /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); R_SEXP_to_vector(distances, &c_distances); - if (0 != R_SEXP_to_vector_copy(weights, &c_weights)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_vector_copy(weights, &c_weights)); IGRAPH_FINALLY(igraph_vector_destroy, &c_weights); /* Call igraph */ IGRAPH_R_CHECK(igraph_layout_umap_compute_weights(&c_graph, &c_distances, &c_weights)); @@ -7365,9 +7119,7 @@ SEXP R_igraph_similarity_dice(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -7404,12 +7156,10 @@ SEXP R_igraph_similarity_dice_es(SEXP graph, SEXP es, SEXP mode, SEXP loops) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_es_data; - R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data)); c_mode = (igraph_neimode_t) Rf_asInteger(mode); IGRAPH_R_CHECK_BOOL(loops); c_loops = LOGICAL(loops)[0]; @@ -7443,9 +7193,7 @@ SEXP R_igraph_similarity_dice_pairs(SEXP graph, SEXP pairs, SEXP mode, SEXP loop SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); R_SEXP_to_vector_int_copy(pairs, &c_pairs); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_pairs); @@ -7481,9 +7229,7 @@ SEXP R_igraph_similarity_inverse_log_weighted(SEXP graph, SEXP vids, SEXP mode) SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -7518,9 +7264,7 @@ SEXP R_igraph_similarity_jaccard(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -7557,12 +7301,10 @@ SEXP R_igraph_similarity_jaccard_es(SEXP graph, SEXP es, SEXP mode, SEXP loops) SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_es_data; - R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(es, &c_graph, &c_es, &c_es_data)); c_mode = (igraph_neimode_t) Rf_asInteger(mode); IGRAPH_R_CHECK_BOOL(loops); c_loops = LOGICAL(loops)[0]; @@ -7596,9 +7338,7 @@ SEXP R_igraph_similarity_jaccard_pairs(SEXP graph, SEXP pairs, SEXP mode, SEXP l SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); R_SEXP_to_vector_int_copy(pairs, &c_pairs); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_pairs); @@ -7633,9 +7373,9 @@ SEXP R_igraph_compare_communities(SEXP comm1, SEXP comm2, SEXP method) { SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int_copy(comm1, &c_comm1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(comm1, &c_comm1)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_comm1); - R_SEXP_to_vector_int_copy(comm2, &c_comm2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(comm2, &c_comm2)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_comm2); c_method = (igraph_community_comparison_t) Rf_asInteger(method); /* Call igraph */ @@ -7670,15 +7410,17 @@ SEXP R_igraph_modularity(SEXP graph, SEXP membership, SEXP weights, SEXP resolut SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector_int_copy(membership, &c_membership); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(membership, &c_membership)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } IGRAPH_R_CHECK_REAL(resolution); c_resolution = REAL(resolution)[0]; IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_modularity(&c_graph, &c_membership, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_resolution, c_directed, &c_modularity)); + IGRAPH_R_CHECK(igraph_modularity(&c_graph, &c_membership, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, c_directed, &c_modularity)); /* Convert output */ igraph_vector_int_destroy(&c_membership); @@ -7706,17 +7448,17 @@ SEXP R_igraph_modularity_matrix(SEXP graph, SEXP weights, SEXP resolution, SEXP SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } IGRAPH_R_CHECK_REAL(resolution); c_resolution = REAL(resolution)[0]; - if (0 != igraph_matrix_init(&c_modmat, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_modmat, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_modmat); IGRAPH_R_CHECK_BOOL(directed); c_directed = LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_modularity_matrix(&c_graph, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_resolution, &c_modmat, c_directed)); + IGRAPH_R_CHECK(igraph_modularity_matrix(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, &c_modmat, c_directed)); /* Convert output */ PROTECT(modmat=R_igraph_matrix_to_SEXP(&c_modmat)); @@ -7743,9 +7485,7 @@ SEXP R_igraph_community_fluid_communities(SEXP graph, SEXP no_of_communities) { R_SEXP_to_igraph(graph, &c_graph); IGRAPH_R_CHECK_INT(no_of_communities); c_no_of_communities = (igraph_integer_t) REAL(no_of_communities)[0]; - if (0 != igraph_vector_int_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); /* Call igraph */ IGRAPH_R_CHECK(igraph_community_fluid_communities(&c_graph, c_no_of_communities, &c_membership)); @@ -7776,12 +7516,12 @@ SEXP R_igraph_community_label_propagation(SEXP graph, SEXP mode, SEXP weights, S SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } if (!Rf_isNull(initial)) { R_SEXP_to_vector_int_copy(initial, &c_initial); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_initial); @@ -7793,7 +7533,7 @@ SEXP R_igraph_community_label_propagation(SEXP graph, SEXP mode, SEXP weights, S R_SEXP_to_vector_bool(fixed, &c_fixed); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_label_propagation(&c_graph, &c_membership, c_mode, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), (Rf_isNull(initial) ? 0 : &c_initial), (Rf_isNull(fixed) ? 0 : &c_fixed))); + IGRAPH_R_CHECK(igraph_community_label_propagation(&c_graph, &c_membership, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), (Rf_isNull(initial) ? 0 : &c_initial), (Rf_isNull(fixed) ? 0 : &c_fixed))); /* Convert output */ PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); @@ -7825,23 +7565,19 @@ SEXP R_igraph_community_multilevel(SEXP graph, SEXP weights, SEXP resolution) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } IGRAPH_R_CHECK_REAL(resolution); c_resolution = REAL(resolution)[0]; - if (0 != igraph_vector_int_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); - if (0 != igraph_matrix_int_init(&c_memberships, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_int_init(&c_memberships, 0, 0)); IGRAPH_FINALLY(igraph_matrix_int_destroy, &c_memberships); - if (0 != igraph_vector_init(&c_modularity, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_modularity, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_modularity); /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_multilevel(&c_graph, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_resolution, &c_membership, &c_memberships, &c_modularity)); + IGRAPH_R_CHECK(igraph_community_multilevel(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, &c_membership, &c_memberships, &c_modularity)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -7883,13 +7619,13 @@ SEXP R_igraph_community_optimal_modularity(SEXP graph, SEXP weights) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_optimal_modularity(&c_graph, &c_modularity, &c_membership, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)))); + IGRAPH_R_CHECK(igraph_community_optimal_modularity(&c_graph, &c_modularity, &c_membership, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -7931,8 +7667,12 @@ SEXP R_igraph_community_leiden(SEXP graph, SEXP weights, SEXP vertex_weights, SE SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } + if (!Rf_isNull(vertex_weights)) { + R_SEXP_to_vector(vertex_weights, &c_vertex_weights); + } IGRAPH_R_CHECK_REAL(resolution); c_resolution = REAL(resolution)[0]; IGRAPH_R_CHECK_REAL(beta); @@ -7942,7 +7682,7 @@ SEXP R_igraph_community_leiden(SEXP graph, SEXP weights, SEXP vertex_weights, SE IGRAPH_R_CHECK_INT(n_iterations); c_n_iterations = (igraph_integer_t) REAL(n_iterations)[0]; if (!Rf_isNull(membership)) { - R_SEXP_to_vector_int_copy(membership, &c_membership); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(membership, &c_membership)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); @@ -7950,7 +7690,7 @@ SEXP R_igraph_community_leiden(SEXP graph, SEXP weights, SEXP vertex_weights, SE } c_nb_clusters=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_leiden(&c_graph, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), (Rf_isNull(vertex_weights) ? 0 : (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights)), c_resolution, c_beta, c_start, c_n_iterations, &c_membership, &c_nb_clusters, &c_quality)); + IGRAPH_R_CHECK(igraph_community_leiden(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), c_resolution, c_beta, c_start, c_n_iterations, &c_membership, &c_nb_clusters, &c_quality)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -7989,9 +7729,9 @@ SEXP R_igraph_split_join_distance(SEXP comm1, SEXP comm2) { SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_vector_int_copy(comm1, &c_comm1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(comm1, &c_comm1)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_comm1); - R_SEXP_to_vector_int_copy(comm2, &c_comm2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(comm2, &c_comm2)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_comm2); c_distance12=0; c_distance21=0; @@ -8037,16 +7777,14 @@ SEXP R_igraph_community_infomap(SEXP graph, SEXP e_weights, SEXP v_weights, SEXP SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(e_weights)) { R_SEXP_to_vector(e_weights, &c_e_weights); } - if (!Rf_isNull(v_weights)) { R_SEXP_to_vector(v_weights, &c_v_weights); } + R_SEXP_to_vector(e_weights, &c_e_weights); + R_SEXP_to_vector(v_weights, &c_v_weights); IGRAPH_R_CHECK_INT(nb_trials); c_nb_trials = (igraph_integer_t) REAL(nb_trials)[0]; - if (0 != igraph_vector_int_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_membership, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_infomap(&c_graph, (Rf_isNull(e_weights) ? 0 : &c_e_weights), (Rf_isNull(v_weights) ? 0 : &c_v_weights), c_nb_trials, &c_membership, &c_codelength)); + IGRAPH_R_CHECK(igraph_community_infomap(&c_graph, &c_e_weights, &c_v_weights, c_nb_trials, &c_membership, &c_codelength)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -8080,9 +7818,7 @@ SEXP R_igraph_hrg_fit(SEXP graph, SEXP hrg, SEXP start, SEXP steps) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); IGRAPH_R_CHECK_BOOL(start); c_start = LOGICAL(start)[0]; @@ -8112,9 +7848,7 @@ SEXP R_igraph_hrg_sample(SEXP hrg) { SEXP r_result; /* Convert input */ - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); /* Call igraph */ IGRAPH_R_CHECK(igraph_hrg_sample(&c_hrg, &c_sample)); @@ -8144,13 +7878,9 @@ SEXP R_igraph_hrg_sample_many(SEXP hrg, SEXP num_samples) { SEXP r_result; /* Convert input */ - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); - if (0 != igraph_graph_list_init(&c_samples, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_graph_list_init(&c_samples, 0)); IGRAPH_FINALLY(igraph_graph_list_destroy, &c_samples); IGRAPH_R_CHECK_INT(num_samples); c_num_samples = (igraph_integer_t) REAL(num_samples)[0]; @@ -8180,9 +7910,7 @@ SEXP R_igraph_hrg_game(SEXP hrg) { SEXP r_result; /* Convert input */ - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); /* Call igraph */ IGRAPH_R_CHECK(igraph_hrg_game(&c_graph, &c_hrg)); @@ -8217,17 +7945,11 @@ SEXP R_igraph_hrg_consensus(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples) SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_parents, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_parents, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parents); - if (0 != igraph_vector_init(&c_weights, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_weights, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_weights); - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); IGRAPH_R_CHECK_BOOL(start); c_start = LOGICAL(start)[0]; @@ -8279,17 +8001,11 @@ SEXP R_igraph_hrg_predict(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples, SE SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); - if (0 != igraph_vector_init(&c_prob, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_prob, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_prob); - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); IGRAPH_R_CHECK_BOOL(start); c_start = LOGICAL(start)[0]; @@ -8337,9 +8053,7 @@ SEXP R_igraph_hrg_create(SEXP graph, SEXP prob) { SEXP r_result; /* Convert input */ - if (0 != igraph_hrg_init(&c_hrg, 0)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_hrg_init(&c_hrg, 0)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); R_SEXP_to_igraph(graph, &c_graph); R_SEXP_to_vector(prob, &c_prob); @@ -8366,9 +8080,7 @@ SEXP R_igraph_hrg_resize(SEXP hrg, SEXP newsize) { SEXP r_result; /* Convert input */ - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); IGRAPH_R_CHECK_INT(newsize); c_newsize = (igraph_integer_t) REAL(newsize)[0]; @@ -8394,9 +8106,7 @@ SEXP R_igraph_hrg_size(SEXP hrg) { igraph_integer_t c_result; SEXP r_result; /* Convert input */ - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); /* Call igraph */ c_result=igraph_hrg_size(&c_hrg); @@ -8424,13 +8134,9 @@ SEXP R_igraph_from_hrg_dendrogram(SEXP hrg) { SEXP r_result, r_names; /* Convert input */ - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); - if (0 != igraph_vector_init(&c_prob, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_prob, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_prob); /* Call igraph */ IGRAPH_R_CHECK(igraph_from_hrg_dendrogram(&c_graph, &c_hrg, &c_prob)); @@ -8473,15 +8179,13 @@ SEXP R_igraph_get_adjacency_sparse(SEXP graph, SEXP type, SEXP weights, SEXP loo SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_sparsemat_init(&c_sparsemat, 0, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_sparsemat_init(&c_sparsemat, 0, 0, 0)); IGRAPH_FINALLY(igraph_sparsemat_destroy, &c_sparsemat); c_type = (igraph_get_adjacency_t) Rf_asInteger(type); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_loops = (igraph_loops_t) Rf_asInteger(loops); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_adjacency_sparse(&c_graph, &c_sparsemat, c_type, (Rf_isNull(weights) ? 0 : &c_weights), c_loops)); + IGRAPH_R_CHECK(igraph_get_adjacency_sparse(&c_graph, &c_sparsemat, c_type, &c_weights, c_loops)); /* Convert output */ PROTECT(sparsemat=R_igraph_sparsemat_to_SEXP(&c_sparsemat)); @@ -8507,15 +8211,13 @@ SEXP R_igraph_get_stochastic(SEXP graph, SEXP column_wise, SEXP weights) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); IGRAPH_R_CHECK_BOOL(column_wise); c_column_wise = LOGICAL(column_wise)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_stochastic(&c_graph, &c_res, c_column_wise, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_get_stochastic(&c_graph, &c_res, c_column_wise, &c_weights)); /* Convert output */ PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); @@ -8541,15 +8243,13 @@ SEXP R_igraph_get_stochastic_sparse(SEXP graph, SEXP column_wise, SEXP weights) SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_sparsemat_init(&c_sparsemat, 0, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_sparsemat_init(&c_sparsemat, 0, 0, 0)); IGRAPH_FINALLY(igraph_sparsemat_destroy, &c_sparsemat); IGRAPH_R_CHECK_BOOL(column_wise); c_column_wise = LOGICAL(column_wise)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_stochastic_sparse(&c_graph, &c_sparsemat, c_column_wise, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_get_stochastic_sparse(&c_graph, &c_sparsemat, c_column_wise, &c_weights)); /* Convert output */ PROTECT(sparsemat=R_igraph_sparsemat_to_SEXP(&c_sparsemat)); @@ -8632,9 +8332,7 @@ SEXP R_igraph_motifs_randesu(SEXP graph, SEXP size, SEXP cut_prob) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_hist, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_hist, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); IGRAPH_R_CHECK_INT(size); c_size = (igraph_integer_t) REAL(size)[0]; @@ -8679,7 +8377,7 @@ SEXP R_igraph_motifs_randesu_estimate(SEXP graph, SEXP size, SEXP cut_prob, SEXP IGRAPH_R_CHECK_INT(sample_size); c_sample_size = (igraph_integer_t) REAL(sample_size)[0]; if (!Rf_isNull(sample)) { - R_SEXP_to_vector_int_copy(sample, &c_sample); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(sample, &c_sample)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_sample); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_sample, 0)); @@ -8784,9 +8482,7 @@ SEXP R_igraph_triad_census(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_triad_census(&c_graph, &c_res)); @@ -8814,9 +8510,7 @@ SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); @@ -8849,14 +8543,12 @@ SEXP R_igraph_local_scan_0(SEXP graph, SEXP weights, SEXP mode) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_0(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_local_scan_0(&c_graph, &c_res, &c_weights, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -8884,14 +8576,12 @@ SEXP R_igraph_local_scan_0_them(SEXP us, SEXP them, SEXP weights_them, SEXP mode /* Convert input */ R_SEXP_to_igraph(us, &c_us); R_SEXP_to_igraph(them, &c_them); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + R_SEXP_to_vector(weights_them, &c_weights_them); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_0_them(&c_us, &c_them, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + IGRAPH_R_CHECK(igraph_local_scan_0_them(&c_us, &c_them, &c_res, &c_weights_them, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -8917,14 +8607,12 @@ SEXP R_igraph_local_scan_1_ecount(SEXP graph, SEXP weights, SEXP mode) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_1_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_local_scan_1_ecount(&c_graph, &c_res, &c_weights, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -8952,14 +8640,12 @@ SEXP R_igraph_local_scan_1_ecount_them(SEXP us, SEXP them, SEXP weights_them, SE /* Convert input */ R_SEXP_to_igraph(us, &c_us); R_SEXP_to_igraph(them, &c_them); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + R_SEXP_to_vector(weights_them, &c_weights_them); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_1_ecount_them(&c_us, &c_them, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + IGRAPH_R_CHECK(igraph_local_scan_1_ecount_them(&c_us, &c_them, &c_res, &c_weights_them, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -8988,14 +8674,12 @@ SEXP R_igraph_local_scan_k_ecount(SEXP graph, SEXP k, SEXP weights, SEXP mode) { R_SEXP_to_igraph(graph, &c_graph); IGRAPH_R_CHECK_INT(k); c_k = (igraph_integer_t) REAL(k)[0]; - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_k_ecount(&c_graph, c_k, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_local_scan_k_ecount(&c_graph, c_k, &c_res, &c_weights, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -9026,14 +8710,12 @@ SEXP R_igraph_local_scan_k_ecount_them(SEXP us, SEXP them, SEXP k, SEXP weights_ R_SEXP_to_igraph(them, &c_them); IGRAPH_R_CHECK_INT(k); c_k = (igraph_integer_t) REAL(k)[0]; - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + R_SEXP_to_vector(weights_them, &c_weights_them); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_k_ecount_them(&c_us, &c_them, c_k, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + IGRAPH_R_CHECK(igraph_local_scan_k_ecount_them(&c_us, &c_them, c_k, &c_res, &c_weights_them, c_mode)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -9059,15 +8741,13 @@ SEXP R_igraph_local_scan_neighborhood_ecount(SEXP graph, SEXP weights, SEXP neig SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - R_igraph_SEXP_to_vector_int_list(neighborhoods, &c_neighborhoods); + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(R_igraph_SEXP_to_vector_int_list(neighborhoods, &c_neighborhoods)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_neighborhoods); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_neighborhood_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), &c_neighborhoods)); + IGRAPH_R_CHECK(igraph_local_scan_neighborhood_ecount(&c_graph, &c_res, &c_weights, &c_neighborhoods)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -9095,15 +8775,13 @@ SEXP R_igraph_local_scan_subset_ecount(SEXP graph, SEXP weights, SEXP subsets) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - R_igraph_SEXP_to_vector_int_list(subsets, &c_subsets); + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(R_igraph_SEXP_to_vector_int_list(subsets, &c_subsets)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_subsets); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_subset_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), &c_subsets)); + IGRAPH_R_CHECK(igraph_local_scan_subset_ecount(&c_graph, &c_res, &c_weights, &c_subsets)); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); @@ -9129,9 +8807,7 @@ SEXP R_igraph_list_triangles(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_list_triangles(&c_graph, &c_res)); @@ -9195,13 +8871,9 @@ SEXP R_igraph_induced_subgraph_map(SEXP graph, SEXP vids, SEXP impl) { igraph_vector_int_t c_vids_data; R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); c_impl = (igraph_subgraph_implementation_t) Rf_asInteger(impl); - if (0 != igraph_vector_int_init(&c_map, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_map, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map); - if (0 != igraph_vector_int_init(&c_invmap, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_invmap, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_invmap); /* Call igraph */ IGRAPH_R_CHECK(igraph_induced_subgraph_map(&c_graph, &c_res, c_vids, c_impl, &c_map, &c_invmap)); @@ -9249,13 +8921,13 @@ SEXP R_igraph_gomory_hu_tree(SEXP graph, SEXP capacity) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_flows, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_flows, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_flows); - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + if (!Rf_isNull(capacity)) { + R_SEXP_to_vector(capacity, &c_capacity); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_gomory_hu_tree(&c_graph, &c_tree, &c_flows, (Rf_isNull(capacity) ? 0 : (Rf_isNull(capacity) ? 0 : &c_capacity)))); + IGRAPH_R_CHECK(igraph_gomory_hu_tree(&c_graph, &c_tree, &c_flows, (Rf_isNull(capacity) ? 0 : &c_capacity))); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -9303,27 +8975,21 @@ SEXP R_igraph_maxflow(SEXP graph, SEXP source, SEXP target, SEXP capacity) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_flow, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_flow, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_flow); - if (0 != igraph_vector_int_init(&c_cut, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_cut, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cut); - if (0 != igraph_vector_int_init(&c_partition1, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition1, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition1); - if (0 != igraph_vector_int_init(&c_partition2, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition2, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition2); c_source = (igraph_integer_t) REAL(source)[0]; c_target = (igraph_integer_t) REAL(target)[0]; - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + if (!Rf_isNull(capacity)) { + R_SEXP_to_vector(capacity, &c_capacity); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_maxflow(&c_graph, &c_value, &c_flow, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : (Rf_isNull(capacity) ? 0 : &c_capacity)), &c_stats)); + IGRAPH_R_CHECK(igraph_maxflow(&c_graph, &c_value, &c_flow, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_stats)); /* Convert output */ PROTECT(r_result=NEW_LIST(6)); @@ -9378,15 +9044,13 @@ SEXP R_igraph_residual_graph(SEXP graph, SEXP capacity, SEXP flow) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } - if (0 != igraph_vector_init(&c_residual_capacity, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(capacity, &c_capacity); + IGRAPH_R_CHECK(igraph_vector_init(&c_residual_capacity, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_residual_capacity); residual_capacity=R_GlobalEnv; /* hack to have a non-NULL value */ R_SEXP_to_vector(flow, &c_flow); /* Call igraph */ - IGRAPH_R_CHECK(igraph_residual_graph(&c_graph, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_residual, (Rf_isNull(residual_capacity) ? 0 : &c_residual_capacity), &c_flow)); + IGRAPH_R_CHECK(igraph_residual_graph(&c_graph, &c_capacity, &c_residual, &c_residual_capacity, &c_flow)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -9423,10 +9087,10 @@ SEXP R_igraph_reverse_residual_graph(SEXP graph, SEXP capacity, SEXP flow) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + R_SEXP_to_vector(capacity, &c_capacity); R_SEXP_to_vector(flow, &c_flow); /* Call igraph */ - IGRAPH_R_CHECK(igraph_reverse_residual_graph(&c_graph, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_residual, &c_flow)); + IGRAPH_R_CHECK(igraph_reverse_residual_graph(&c_graph, &c_capacity, &c_residual, &c_flow)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_residual); @@ -9460,23 +9124,19 @@ SEXP R_igraph_st_mincut(SEXP graph, SEXP source, SEXP target, SEXP capacity) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_cut, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_cut, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cut); - if (0 != igraph_vector_int_init(&c_partition1, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition1, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition1); - if (0 != igraph_vector_int_init(&c_partition2, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition2, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition2); c_source = (igraph_integer_t) REAL(source)[0]; c_target = (igraph_integer_t) REAL(target)[0]; - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + if (!Rf_isNull(capacity)) { + R_SEXP_to_vector(capacity, &c_capacity); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_st_mincut(&c_graph, &c_value, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : (Rf_isNull(capacity) ? 0 : &c_capacity)))); + IGRAPH_R_CHECK(igraph_st_mincut(&c_graph, &c_value, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity))); /* Convert output */ PROTECT(r_result=NEW_LIST(4)); @@ -9526,13 +9186,9 @@ SEXP R_igraph_dominator_tree(SEXP graph, SEXP root, SEXP mode) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); c_root = (igraph_integer_t) REAL(root)[0]; - if (0 != igraph_vector_int_init(&c_dom, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_dom, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_dom); - if (0 != igraph_vector_int_init(&c_leftout, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_leftout, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_leftout); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ @@ -9580,13 +9236,9 @@ SEXP R_igraph_all_st_cuts(SEXP graph, SEXP source, SEXP target) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_cuts, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_cuts, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cuts); - if (0 != igraph_vector_int_list_init(&c_partition1s, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_partition1s, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_partition1s); c_source = (igraph_integer_t) REAL(source)[0]; c_target = (igraph_integer_t) REAL(target)[0]; @@ -9632,19 +9284,17 @@ SEXP R_igraph_all_st_mincuts(SEXP graph, SEXP source, SEXP target, SEXP capacity SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_cuts, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_cuts, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cuts); - if (0 != igraph_vector_int_list_init(&c_partition1s, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_partition1s, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_partition1s); c_source = (igraph_integer_t) REAL(source)[0]; c_target = (igraph_integer_t) REAL(target)[0]; - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + if (!Rf_isNull(capacity)) { + R_SEXP_to_vector(capacity, &c_capacity); + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_all_st_mincuts(&c_graph, &c_value, &c_cuts, &c_partition1s, c_source, c_target, (Rf_isNull(capacity) ? 0 : (Rf_isNull(capacity) ? 0 : &c_capacity)))); + IGRAPH_R_CHECK(igraph_all_st_mincuts(&c_graph, &c_value, &c_cuts, &c_partition1s, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity))); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -9684,13 +9334,11 @@ SEXP R_igraph_even_tarjan_reduction(SEXP graph) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_capacity, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_capacity, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_capacity); capacity=R_GlobalEnv; /* hack to have a non-NULL value */ /* Call igraph */ - IGRAPH_R_CHECK(igraph_even_tarjan_reduction(&c_graph, &c_graphbar, (Rf_isNull(capacity) ? 0 : &c_capacity))); + IGRAPH_R_CHECK(igraph_even_tarjan_reduction(&c_graph, &c_graphbar, &c_capacity)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -9783,9 +9431,7 @@ SEXP R_igraph_all_minimal_st_separators(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_separators, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_separators, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_separators); /* Call igraph */ IGRAPH_R_CHECK(igraph_all_minimal_st_separators(&c_graph, &c_separators)); @@ -9812,9 +9458,7 @@ SEXP R_igraph_minimum_size_separators(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_separators, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_separators, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_separators); /* Call igraph */ IGRAPH_R_CHECK(igraph_minimum_size_separators(&c_graph, &c_separators)); @@ -9893,7 +9537,7 @@ SEXP R_igraph_isoclass_subgraph(SEXP graph, SEXP vids) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector_int_copy(vids, &c_vids); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vids, &c_vids)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vids); c_isoclass=0; /* Call igraph */ @@ -9969,39 +9613,35 @@ SEXP R_igraph_isomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); - if (0 != igraph_vector_int_init(&c_map12, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_map12, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map12); - if (0 != igraph_vector_int_init(&c_map21, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_map21, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map21); /* Call igraph */ - IGRAPH_R_CHECK(igraph_isomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1)), (Rf_isNull(vertex_color2) ? 0 : (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2)), (Rf_isNull(edge_color1) ? 0 : (Rf_isNull(edge_color1) ? 0 : &c_edge_color1)), (Rf_isNull(edge_color2) ? 0 : (Rf_isNull(edge_color2) ? 0 : &c_edge_color2)), &c_iso, &c_map12, &c_map21, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_isomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_iso, &c_map12, &c_map21, 0, 0, 0)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -10057,32 +9697,32 @@ SEXP R_igraph_count_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); c_count=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_count_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_count_isomorphisms_vf2(&c_graph1, &c_graph2, &c_vertex_color1, &c_vertex_color2, &c_edge_color1, &c_edge_color2, &c_count, 0, 0, 0)); /* Convert output */ igraph_vector_int_destroy(&c_vertex_color1); @@ -10123,35 +9763,33 @@ SEXP R_igraph_get_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); - if (0 != igraph_vector_int_list_init(&c_maps, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_maps, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_maps); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_get_isomorphisms_vf2(&c_graph1, &c_graph2, &c_vertex_color1, &c_vertex_color2, &c_edge_color1, &c_edge_color2, &c_maps, 0, 0, 0)); /* Convert output */ igraph_vector_int_destroy(&c_vertex_color1); @@ -10223,39 +9861,35 @@ SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SE R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); - if (0 != igraph_vector_int_init(&c_map12, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_map12, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map12); - if (0 != igraph_vector_int_init(&c_map21, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_map21, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map21); /* Call igraph */ - IGRAPH_R_CHECK(igraph_subisomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1)), (Rf_isNull(vertex_color2) ? 0 : (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2)), (Rf_isNull(edge_color1) ? 0 : (Rf_isNull(edge_color1) ? 0 : &c_edge_color1)), (Rf_isNull(edge_color2) ? 0 : (Rf_isNull(edge_color2) ? 0 : &c_edge_color2)), &c_iso, &c_map12, &c_map21, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_subisomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_iso, &c_map12, &c_map21, 0, 0, 0)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -10311,32 +9945,32 @@ SEXP R_igraph_count_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_co R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); c_count=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_count_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_count_subisomorphisms_vf2(&c_graph1, &c_graph2, &c_vertex_color1, &c_vertex_color2, &c_edge_color1, &c_edge_color2, &c_count, 0, 0, 0)); /* Convert output */ igraph_vector_int_destroy(&c_vertex_color1); @@ -10377,35 +10011,33 @@ SEXP R_igraph_get_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_colo R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); if (!Rf_isNull(vertex_color1)) { - R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color1, &c_vertex_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color1); if (!Rf_isNull(vertex_color2)) { - R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(vertex_color2, &c_vertex_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color2); if (!Rf_isNull(edge_color1)) { - R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color1, &c_edge_color1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color1); if (!Rf_isNull(edge_color2)) { - R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(edge_color2, &c_edge_color2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color2); - if (0 != igraph_vector_int_list_init(&c_maps, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_maps, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_maps); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_get_subisomorphisms_vf2(&c_graph1, &c_graph2, &c_vertex_color1, &c_vertex_color2, &c_edge_color1, &c_edge_color2, &c_maps, 0, 0, 0)); /* Convert output */ igraph_vector_int_destroy(&c_vertex_color1); @@ -10442,18 +10074,16 @@ SEXP R_igraph_canonical_permutation(SEXP graph, SEXP colors, SEXP sh) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(colors)) { - R_SEXP_to_vector_int_copy(colors, &c_colors); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(colors, &c_colors)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); - if (0 != igraph_vector_int_init(&c_labeling, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_labeling, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_labeling); c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); /* Call igraph */ - IGRAPH_R_CHECK(igraph_canonical_permutation(&c_graph, (Rf_isNull(colors) ? 0 : (Rf_isNull(colors) ? 0 : &c_colors)), &c_labeling, c_sh, &c_info)); + IGRAPH_R_CHECK(igraph_canonical_permutation(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), &c_labeling, c_sh, &c_info)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -10533,28 +10163,24 @@ SEXP R_igraph_isomorphic_bliss(SEXP graph1, SEXP graph2, SEXP colors1, SEXP colo R_SEXP_to_igraph(graph1, &c_graph1); R_SEXP_to_igraph(graph2, &c_graph2); if (!Rf_isNull(colors1)) { - R_SEXP_to_vector_int_copy(colors1, &c_colors1); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(colors1, &c_colors1)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors1, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors1); if (!Rf_isNull(colors2)) { - R_SEXP_to_vector_int_copy(colors2, &c_colors2); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(colors2, &c_colors2)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors2, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors2); - if (0 != igraph_vector_int_init(&c_map12, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_map12, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map12); - if (0 != igraph_vector_int_init(&c_map21, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_map21, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map21); c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); /* Call igraph */ - IGRAPH_R_CHECK(igraph_isomorphic_bliss(&c_graph1, &c_graph2, (Rf_isNull(colors1) ? 0 : (Rf_isNull(colors1) ? 0 : &c_colors1)), (Rf_isNull(colors2) ? 0 : (Rf_isNull(colors2) ? 0 : &c_colors2)), &c_iso, &c_map12, &c_map21, c_sh, &c_info1, &c_info2)); + IGRAPH_R_CHECK(igraph_isomorphic_bliss(&c_graph1, &c_graph2, (Rf_isNull(colors1) ? 0 : &c_colors1), (Rf_isNull(colors2) ? 0 : &c_colors2), &c_iso, &c_map12, &c_map21, c_sh, &c_info1, &c_info2)); /* Convert output */ PROTECT(r_result=NEW_LIST(5)); @@ -10607,14 +10233,14 @@ SEXP R_igraph_count_automorphisms(SEXP graph, SEXP colors, SEXP sh) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(colors)) { - R_SEXP_to_vector_int_copy(colors, &c_colors); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(colors, &c_colors)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); /* Call igraph */ - IGRAPH_R_CHECK(igraph_count_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : (Rf_isNull(colors) ? 0 : &c_colors)), c_sh, &c_info)); + IGRAPH_R_CHECK(igraph_count_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), c_sh, &c_info)); /* Convert output */ igraph_vector_int_destroy(&c_colors); @@ -10644,18 +10270,16 @@ SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(colors)) { - R_SEXP_to_vector_int_copy(colors, &c_colors); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(colors, &c_colors)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); - if (0 != igraph_vector_int_list_init(&c_generators, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_generators, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_generators); c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); /* Call igraph */ - IGRAPH_R_CHECK(igraph_automorphism_group(&c_graph, (Rf_isNull(colors) ? 0 : (Rf_isNull(colors) ? 0 : &c_colors)), &c_generators, c_sh, &c_info)); + IGRAPH_R_CHECK(igraph_automorphism_group(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), &c_generators, c_sh, &c_info)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -10694,13 +10318,9 @@ SEXP R_igraph_simplify_and_colorize(SEXP graph) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_vertex_color, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_color, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color); - if (0 != igraph_vector_int_init(&c_edge_color, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_color, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color); /* Call igraph */ IGRAPH_R_CHECK(igraph_simplify_and_colorize(&c_graph, &c_res, &c_vertex_color, &c_edge_color)); @@ -10774,11 +10394,13 @@ SEXP R_igraph_is_matching(SEXP graph, SEXP types, SEXP matching) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + if (!Rf_isNull(types)) { + R_SEXP_to_vector_bool(types, &c_types); + } R_SEXP_to_vector_int_copy(matching, &c_matching); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_matching); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_matching(&c_graph, (Rf_isNull(types) ? 0 : (Rf_isNull(types) ? 0 : &c_types)), &c_matching, &c_res)); + IGRAPH_R_CHECK(igraph_is_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching, &c_res)); /* Convert output */ igraph_vector_int_destroy(&c_matching); @@ -10805,11 +10427,13 @@ SEXP R_igraph_is_maximal_matching(SEXP graph, SEXP types, SEXP matching) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + if (!Rf_isNull(types)) { + R_SEXP_to_vector_bool(types, &c_types); + } R_SEXP_to_vector_int_copy(matching, &c_matching); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_matching); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_maximal_matching(&c_graph, (Rf_isNull(types) ? 0 : (Rf_isNull(types) ? 0 : &c_types)), &c_matching, &c_res)); + IGRAPH_R_CHECK(igraph_is_maximal_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching, &c_res)); /* Convert output */ igraph_vector_int_destroy(&c_matching); @@ -10841,17 +10465,19 @@ SEXP R_igraph_maximum_bipartite_matching(SEXP graph, SEXP types, SEXP weights, S SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - c_matching_size=0; - if (0 != igraph_vector_int_init(&c_matching, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + if (!Rf_isNull(types)) { + R_SEXP_to_vector_bool(types, &c_types); } + c_matching_size=0; + IGRAPH_R_CHECK(igraph_vector_int_init(&c_matching, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_matching); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } IGRAPH_R_CHECK_REAL(eps); c_eps = REAL(eps)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_maximum_bipartite_matching(&c_graph, (Rf_isNull(types) ? 0 : (Rf_isNull(types) ? 0 : &c_types)), &c_matching_size, &c_matching_weight, &c_matching, (Rf_isNull(weights) ? 0 : (Rf_isNull(weights) ? 0 : &c_weights)), c_eps)); + IGRAPH_R_CHECK(igraph_maximum_bipartite_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching_size, &c_matching_weight, &c_matching, (Rf_isNull(weights) ? 0 : &c_weights), c_eps)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); @@ -10901,26 +10527,18 @@ SEXP R_igraph_eigen_adjacency(SEXP graph, SEXP algorithm, SEXP which, SEXP optio c_algorithm = (igraph_eigen_algorithm_t) Rf_asInteger(algorithm); R_SEXP_to_igraph_eigen_which(which, &c_which); R_SEXP_to_igraph_arpack_options(options, &c_options); - if (0 != igraph_vector_init(&c_values, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&c_values, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &c_values); - if (0 != igraph_matrix_init(&c_vectors, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_vectors, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); - if (0 != igraph_vector_complex_init(&c_cmplxvalues, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_complex_init(&c_cmplxvalues, 0)); IGRAPH_FINALLY(igraph_vector_complex_destroy, &c_cmplxvalues); cmplxvalues=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_matrix_complex_init(&c_cmplxvectors, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_complex_init(&c_cmplxvectors, 0, 0)); IGRAPH_FINALLY(igraph_matrix_complex_destroy, &c_cmplxvectors); cmplxvectors=R_GlobalEnv; /* hack to have a non-NULL value */ /* Call igraph */ - IGRAPH_R_CHECK(igraph_eigen_adjacency(&c_graph, c_algorithm, &c_which, &c_options, 0, &c_values, &c_vectors, (Rf_isNull(cmplxvalues) ? 0 : &c_cmplxvalues), (Rf_isNull(cmplxvectors) ? 0 : &c_cmplxvectors))); + IGRAPH_R_CHECK(igraph_eigen_adjacency(&c_graph, c_algorithm, &c_which, &c_options, 0, &c_values, &c_vectors, (Rf_isNull(cmplxvalues) ? NULL : &c_cmplxvalues), (Rf_isNull(cmplxvectors) ? NULL : &c_cmplxvectors))); /* Convert output */ PROTECT(r_result=NEW_LIST(5)); @@ -11005,9 +10623,7 @@ SEXP R_igraph_sir(SEXP graph, SEXP beta, SEXP gamma, SEXP no_sim) { c_gamma = REAL(gamma)[0]; IGRAPH_R_CHECK_INT(no_sim); c_no_sim = (igraph_integer_t) REAL(no_sim)[0]; - if (0 != igraph_vector_ptr_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_ptr_init(&c_res, 0)); IGRAPH_FINALLY(R_igraph_sirlist_destroy, &c_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_sir(&c_graph, c_beta, c_gamma, c_no_sim, &c_res)); @@ -11036,13 +10652,9 @@ SEXP R_igraph_convex_hull(SEXP data) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_matrix(data, &c_data); - if (0 != igraph_vector_int_init(&c_resverts, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_resverts, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_resverts); - if (0 != igraph_matrix_init(&c_rescoords, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&c_rescoords, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &c_rescoords); /* Call igraph */ IGRAPH_R_CHECK(igraph_convex_hull(&c_data, &c_resverts, &c_rescoords)); @@ -11107,9 +10719,7 @@ SEXP R_igraph_solve_lsap(SEXP c, SEXP n) { R_SEXP_to_matrix(c, &c_c); IGRAPH_R_CHECK_INT(n); c_n = (igraph_integer_t) REAL(n)[0]; - if (0 != igraph_vector_int_init(&c_p, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_p, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_p); /* Call igraph */ IGRAPH_R_CHECK(igraph_solve_lsap(&c_c, c_n, &c_p)); @@ -11139,13 +10749,9 @@ SEXP R_igraph_find_cycle(SEXP graph, SEXP mode) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_vertices, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertices, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); - if (0 != igraph_vector_int_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ @@ -11220,13 +10826,9 @@ SEXP R_igraph_eulerian_path(SEXP graph) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_edge_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_res); - if (0 != igraph_vector_int_init(&c_vertex_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_eulerian_path(&c_graph, &c_edge_res, &c_vertex_res)); @@ -11265,13 +10867,9 @@ SEXP R_igraph_eulerian_cycle(SEXP graph) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_edge_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_res); - if (0 != igraph_vector_int_init(&c_vertex_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_res); /* Call igraph */ IGRAPH_R_CHECK(igraph_eulerian_cycle(&c_graph, &c_edge_res, &c_vertex_res)); @@ -11311,18 +10909,16 @@ SEXP R_igraph_fundamental_cycles(SEXP graph, SEXP start, SEXP bfs_cutoff, SEXP w SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_basis, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_basis, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_basis); if (!Rf_isNull(start)) { c_start = (igraph_integer_t) REAL(start)[0]; } IGRAPH_R_CHECK_INT(bfs_cutoff); c_bfs_cutoff = (igraph_integer_t) REAL(bfs_cutoff)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_fundamental_cycles(&c_graph, &c_basis, (Rf_isNull(start) ? 0 : c_start), c_bfs_cutoff, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_fundamental_cycles(&c_graph, &c_basis, (Rf_isNull(start) ? 0 : c_start), c_bfs_cutoff, &c_weights)); /* Convert output */ PROTECT(basis=R_igraph_vector_int_list_to_SEXPp1(&c_basis)); @@ -11350,9 +10946,7 @@ SEXP R_igraph_minimum_cycle_basis(SEXP graph, SEXP bfs_cutoff, SEXP complete, SE SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_list_init(&c_basis, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_basis, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_basis); IGRAPH_R_CHECK_INT(bfs_cutoff); c_bfs_cutoff = (igraph_integer_t) REAL(bfs_cutoff)[0]; @@ -11360,9 +10954,9 @@ SEXP R_igraph_minimum_cycle_basis(SEXP graph, SEXP bfs_cutoff, SEXP complete, SE c_complete = LOGICAL(complete)[0]; IGRAPH_R_CHECK_BOOL(use_cycle_order); c_use_cycle_order = LOGICAL(use_cycle_order)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector(weights, &c_weights); /* Call igraph */ - IGRAPH_R_CHECK(igraph_minimum_cycle_basis(&c_graph, &c_basis, c_bfs_cutoff, c_complete, c_use_cycle_order, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_minimum_cycle_basis(&c_graph, &c_basis, c_bfs_cutoff, c_complete, c_use_cycle_order, &c_weights)); /* Convert output */ PROTECT(basis=R_igraph_vector_int_list_to_SEXPp1(&c_basis)); @@ -11427,9 +11021,7 @@ SEXP R_igraph_is_forest(SEXP graph, SEXP mode) { SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_roots, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_roots, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_roots); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ @@ -11495,9 +11087,7 @@ SEXP R_igraph_to_prufer(SEXP graph) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_prufer, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_prufer, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_prufer); /* Call igraph */ IGRAPH_R_CHECK(igraph_to_prufer(&c_graph, &c_prufer)); @@ -11580,9 +11170,7 @@ SEXP R_igraph_random_spanning_tree(SEXP graph, SEXP vid) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); if (!Rf_isNull(vid)) { c_vid = (igraph_integer_t) REAL(vid)[0]; @@ -11645,9 +11233,7 @@ SEXP R_igraph_vertex_coloring_greedy(SEXP graph, SEXP heuristic) { SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_colors, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_colors, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); c_heuristic = (igraph_coloring_greedy_t) Rf_asInteger(heuristic); /* Call igraph */ @@ -11681,7 +11267,7 @@ SEXP R_igraph_deterministic_optimal_imitation(SEXP graph, SEXP vid, SEXP optimal c_vid = (igraph_integer_t) REAL(vid)[0]; c_optimality = (igraph_optimal_t) Rf_asInteger(optimality); R_SEXP_to_vector(quantities, &c_quantities); - R_SEXP_to_vector_int_copy(strategies, &c_strategies); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(strategies, &c_strategies)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_strategies); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ @@ -11711,16 +11297,14 @@ SEXP R_igraph_moran_process(SEXP graph, SEXP weights, SEXP quantities, SEXP stra SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != R_SEXP_to_vector_copy(quantities, &c_quantities)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + R_SEXP_to_vector(weights, &c_weights); + IGRAPH_R_CHECK(R_SEXP_to_vector_copy(quantities, &c_quantities)); IGRAPH_FINALLY(igraph_vector_destroy, &c_quantities); - R_SEXP_to_vector_int_copy(strategies, &c_strategies); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(strategies, &c_strategies)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_strategies); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_moran_process(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_quantities, &c_strategies, c_mode)); + IGRAPH_R_CHECK(igraph_moran_process(&c_graph, &c_weights, &c_quantities, &c_strategies, c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -11761,7 +11345,7 @@ SEXP R_igraph_roulette_wheel_imitation(SEXP graph, SEXP vid, SEXP is_local, SEXP IGRAPH_R_CHECK_BOOL(is_local); c_is_local = LOGICAL(is_local)[0]; R_SEXP_to_vector(quantities, &c_quantities); - R_SEXP_to_vector_int_copy(strategies, &c_strategies); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(strategies, &c_strategies)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_strategies); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ @@ -11795,7 +11379,7 @@ SEXP R_igraph_stochastic_imitation(SEXP graph, SEXP vid, SEXP algo, SEXP quantit c_vid = (igraph_integer_t) REAL(vid)[0]; c_algo = (igraph_imitate_algorithm_t) Rf_asInteger(algo); R_SEXP_to_vector(quantities, &c_quantities); - R_SEXP_to_vector_int_copy(strategies, &c_strategies); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(strategies, &c_strategies)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_strategies); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ @@ -11877,9 +11461,7 @@ SEXP R_igraph_vertex_path_from_edge_path(SEXP graph, SEXP start, SEXP edge_path, c_start = (igraph_integer_t) REAL(start)[0]; R_SEXP_to_vector_int_copy(edge_path, &c_edge_path); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_path); - if (0 != igraph_vector_int_init(&c_vertex_path, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&c_vertex_path, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_path); c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ diff --git a/tools/stimulus/types-RC.yaml b/tools/stimulus/types-RC.yaml index 0b563a9648..95aa1f233e 100644 --- a/tools/stimulus/types-RC.yaml +++ b/tools/stimulus/types-RC.yaml @@ -22,9 +22,7 @@ GRAPH_LIST: CTYPE: igraph_graph_list_t INCONV: OUT: |- - if (0 != igraph_graph_list_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_graph_list_init(&%C%, 0)); IGRAPH_FINALLY(igraph_graph_list_destroy, &%C%); OUTCONV: OUT: |- @@ -117,9 +115,7 @@ INDEX_VECTOR: R_SEXP_to_vector_int_copy(%I%, &%C%); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: IN: |- @@ -136,14 +132,10 @@ VECTOR: INCONV: IN: R_SEXP_to_vector(%I%, &%C%); INOUT: |- - if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_vector_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUTCONV: OUT: |- @@ -157,14 +149,10 @@ VECTOR_BOOL: INCONV: IN: R_SEXP_to_vector_bool(%I%, &%C%); INOUT: |- - if (0 != R_SEXP_to_vector_bool_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_vector_bool_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &%C%); OUT: |- - if (0 != igraph_vector_bool_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &%C%); OUTCONV: OUT: |- @@ -177,12 +165,10 @@ VECTOR_INT: CTYPE: igraph_vector_int_t INCONV: IN: |- - R_SEXP_to_vector_int_copy(%I%, &%C%); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: IN: |- @@ -205,9 +191,7 @@ VECTOR_LIST: INCONV: IN: R_igraph_SEXP_to_vector_list(%I%, &%C%); OUT: |- - if (0 != igraph_vector_list_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_list_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_list_destroy, &%C%); OUTCONV: OUT: |- @@ -219,11 +203,9 @@ VECTOR_INT_LIST: CALL: '&%C%' CTYPE: igraph_vector_int_list_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vector_int_list(%I%, &%C%); } + IN: if (!Rf_isNull(%I%)) { IGRAPH_R_CHECK(R_igraph_SEXP_to_vector_int_list(%I%, &%C%)); } OUT: |- - if (0 != igraph_vector_int_list_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%C%); OUTCONV: OUT: |- @@ -236,12 +218,10 @@ VERTEXSET_LIST: CTYPE: igraph_vector_int_list_t INCONV: IN: |- - R_igraph_SEXP_to_vector_int_list(%I%, &%C%); + IGRAPH_R_CHECK(R_igraph_SEXP_to_vector_int_list(%I%, &%C%)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_list_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%C%); OUTCONV: IN: |- @@ -256,11 +236,10 @@ EDGESET_LIST: CALL: '&%C%' CTYPE: igraph_vector_int_list_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vector_int_list(%I%, &%C%); } + IN: |- + if (!Rf_isNull(%I%)) { IGRAPH_R_CHECK(R_igraph_SEXP_to_vector_int_list(%I%, &%C%)); } OUT: |- - if (0 != igraph_vector_int_list_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%C%); OUTCONV: OUT: |- @@ -278,11 +257,9 @@ EDGE_SELECTOR: INCONV: IN: |- igraph_vector_int_t %C%_data; - R_SEXP_to_igraph_es(%I%, &%C1%, &%C%, &%C%_data); + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(%I%, &%C1%, &%C%, &%C%_data)); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUTCONV: IN: |- @@ -298,21 +275,17 @@ ADJLIST: CTYPE: igraph_adjlist_t INCONV: IN: |- - if (0 != R_SEXP_to_igraph_adjlist(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_adjlist(%I%, &%C%)); OUTCONV: IN: igraph_adjlist_destroy(&%C%); EDGEWEIGHTS: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' + CALL: '&%C%' CTYPE: igraph_vector_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector(%I%, &%C%); } + IN: R_SEXP_to_vector(%I%, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); %I%=R_GlobalEnv; /* hack to have a non-NULL value */ OUTCONV: @@ -322,14 +295,12 @@ EDGEWEIGHTS: IGRAPH_FINALLY_CLEAN(1); VERTEXWEIGHTS: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' + CALL: '&%C%' CTYPE: igraph_vector_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector(%I%, &%C%); } + IN: R_SEXP_to_vector(%I%, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); %I%=R_GlobalEnv; /* hack to have a non-NULL value */ OUTCONV: @@ -339,14 +310,12 @@ VERTEXWEIGHTS: IGRAPH_FINALLY_CLEAN(1); EDGE_CAPACITY: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' + CALL: '&%C%' CTYPE: igraph_vector_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector(%I%, &%C%); } + IN: R_SEXP_to_vector(%I%, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); %I%=R_GlobalEnv; /* hack to have a non-NULL value */ OUTCONV: @@ -361,14 +330,10 @@ MATRIX: INCONV: IN: R_SEXP_to_matrix(%I%, &%C%); INOUT: |- - if (0 != R_SEXP_to_igraph_matrix_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_matrix_destroy, &%C%); OUT: |- - if (0 != igraph_matrix_init(&%C%, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_init(&%C%, 0, 0)); IGRAPH_FINALLY(igraph_matrix_destroy, &%C%); OUTCONV: OUT: |- @@ -384,14 +349,10 @@ MATRIX_INT: R_SEXP_to_matrix_int(%I%, &%C%); IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); INOUT: |- - if (0 != R_SEXP_to_igraph_matrix_int_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_igraph_matrix_int_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); OUT: |- - if (0 != igraph_matrix_int_init(&%C%, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_int_init(&%C%, 0, 0)); IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); OUTCONV: IN: |- @@ -402,22 +363,6 @@ MATRIX_INT: igraph_matrix_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -ARRAY3: - CALL: '&%C%' - CTYPE: igraph_array3_t - INCONV: - IN: R_igraph_SEXP_to_array3(%I%, &%C%); - OUT: |- - if (0 != igraph_array3_init(&%C%, 0, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_array3_destroy, &%C%); - OUTCONV: - OUT: |- - PROTECT(%I%=R_igraph_array3_to_SEXP(&%C%)); - igraph_array3_destroy(&%C%); - IGRAPH_FINALLY_CLEAN(1); - VERTEX: CALL: IN: '%C%' @@ -454,14 +399,10 @@ VERTEX_QTY: INCONV: IN: R_SEXP_to_vector(%I%, &%C%); INOUT: |- - if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_vector_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUTCONV: OUT: |- @@ -475,14 +416,10 @@ ALL_VERTEX_QTY: INCONV: IN: R_SEXP_to_vector(%I%, &%C%); INOUT: |- - if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_vector_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUTCONV: OUT: |- @@ -502,9 +439,7 @@ VERTEX_SELECTOR: igraph_vector_int_t %C%_data; R_SEXP_to_igraph_vs(%I%, &%C1%, &%C%, &%C%_data); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_destroy, &%C%); OUTCONV: IN: |- @@ -523,9 +458,7 @@ VERTEX_INDICES: R_SEXP_to_vector_int_copy(%I%, &%C%); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: IN: |- @@ -544,9 +477,7 @@ VERTEX_INDEX_PAIRS: R_SEXP_to_vector_int_copy(%I%, &%C%); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: IN: |- @@ -565,9 +496,7 @@ EDGE_INDICES: R_SEXP_to_vector_int_copy(%I%, &%C%); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: IN: |- @@ -643,9 +572,7 @@ VECTOR_STR: INCONV: IN: R_igraph_SEXP_to_strvector(%I%, &%C%); OUT: |- - if (0 != igraph_strvector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_strvector_init(&%C%, 0)); IGRAPH_FINALLY(igraph_strvector_destroy, &%C%); OUTCONV: OUT: |- @@ -655,15 +582,13 @@ VECTOR_STR: BIPARTITE_TYPES: CALL: - IN: '(Rf_isNull(%I%) ? 0 : &%C%)' + IN: '&%C%' OUT: '&%C%' CTYPE: igraph_vector_bool_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector_bool(%I%, &%C%); } + IN: R_SEXP_to_vector_bool(%I%, &%C%); OUT: |- - if (0 != igraph_vector_bool_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_bool_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_bool_destroy, &%C%); OUTCONV: OUT: |- @@ -673,21 +598,19 @@ BIPARTITE_TYPES: VERTEX_COLOR: CALL: - IN: '(Rf_isNull(%I%) ? 0 : &%C%)' + IN: '&%C%' OUT: '&%C%' CTYPE: igraph_vector_int_t INCONV: IN: |- if (!Rf_isNull(%I%)) { - R_SEXP_to_vector_int_copy(%I%, &%C%); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(%I%, &%C%)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: IN: |- @@ -700,21 +623,19 @@ VERTEX_COLOR: EDGE_COLOR: CALL: - IN: '(Rf_isNull(%I%) ? 0 : &%C%)' + IN: '&%C%' OUT: '&%C%' CTYPE: igraph_vector_int_t INCONV: IN: |- if (!Rf_isNull(%I%)) { - R_SEXP_to_vector_int_copy(%I%, &%C%); + IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(%I%, &%C%)); } else { IGRAPH_R_CHECK(igraph_vector_int_init(&%C%, 0)); } IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_int_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(graph_vector_int_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: IN: |- @@ -753,19 +674,13 @@ HRG: CALL: '&%C%' INCONV: IN: |- - if (0 != R_SEXP_to_hrg_copy(%I%, &%C%)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_hrg_destroy, &%C%); INOUT: |- - if (0 != R_SEXP_to_hrg_copy(%I%, &%C%)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(%I%, &%C%)); IGRAPH_FINALLY(igraph_hrg_destroy, &%C%); OUT: |- - if (0 != igraph_hrg_init(&%C%, 0)) { - igraph_error("Insufficient memory to create HRG object", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_hrg_init(&%C%, 0)); IGRAPH_FINALLY(igraph_hrg_destroy, &%C%); OUTCONV: IN: |- @@ -786,9 +701,7 @@ SPARSEMAT: INCONV: IN: R_SEXP_to_sparsemat(%I%, &%C%); OUT: |- - if (0 != igraph_sparsemat_init(&%C%, 0, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_sparsemat_init(&%C%, 0, 0, 0)); IGRAPH_FINALLY(igraph_sparsemat_destroy, &%C%); OUTCONV: OUT: |- @@ -808,14 +721,12 @@ SPARSEMATPTR: igraph_sparsemat_destroy(&%C%); SPARSEMAT_OR_0: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' + CALL: '(Rf_isNull(%I%) ? NULL : &%C%)' CTYPE: igraph_sparsemat_t INCONV: IN: if (!Rf_isNull(%I%)) { R_SEXP_to_sparsemat(%I%, &%C%); } OUT: |- - if (0 != igraph_sparsemat_init(&%C%, 0, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_sparsemat_init(&%C%, 0, 0, 0)); IGRAPH_FINALLY(igraph_sparsemat_destroy, &%C%); %I%=R_GlobalEnv; /* hack to have a non-NULL value */ OUTCONV: @@ -825,26 +736,20 @@ SPARSEMAT_OR_0: IGRAPH_FINALLY_CLEAN(1); VECTOR_COMPLEX: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' + CALL: '(Rf_isNull(%I%) ? NULL : &%C%)' CTYPE: igraph_vector_complex_t INCONV: IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector_complex(%I%, &%C%); } INOUT: |- if (!Rf_isNull(%I%)) { - if (0 != R_SEXP_to_vector_complex_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_vector_complex_copy(%I%, &%C%)); } else { - if (0 != igraph_vector_complex_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_complex_init(&%C%, 0)); } IGRAPH_FINALLY(igraph_vector_complex_destroy, &%C%); %I%=NEW_NUMERIC(0); OUT: |- - if (0 != igraph_vector_complex_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_complex_init(&%C%, 0)); IGRAPH_FINALLY(igraph_vector_complex_destroy, &%C%); %I%=R_GlobalEnv; /* hack to have a non-NULL value */ OUTCONV: @@ -854,26 +759,20 @@ VECTOR_COMPLEX: IGRAPH_FINALLY_CLEAN(1); MATRIX_COMPLEX: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' + CALL: '(Rf_isNull(%I%) ? NULL : &%C%)' CTYPE: igraph_matrix_complex_t INCONV: IN: if (!Rf_isNull(%I%)) { R_SEXP_to_matrix_complex(%I%, &%C%); } INOUT: |- if (!Rf_isNull(%I%)) { - if (0 != R_SEXP_to_matrix_complex_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(R_SEXP_to_matrix_complex_copy(%I%, &%C%)); } else { - if (0 != igraph_matrix_complex_init(&%C%, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_complex_init(&%C%, 0, 0)); } IGRAPH_FINALLY(igraph_matrix_complex_destroy, &%C%); %I%=NEW_NUMERIC(0); OUT: |- - if (0 != igraph_matrix_complex_init(&%C%, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_matrix_complex_init(&%C%, 0, 0)); IGRAPH_FINALLY(igraph_matrix_complex_destroy, &%C%); %I%=R_GlobalEnv; /* hack to have a non-NULL value */ OUTCONV: @@ -907,9 +806,7 @@ SIR_LIST: CTYPE: igraph_vector_ptr_t INCONV: OUT: |- - if (0 != igraph_vector_ptr_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + IGRAPH_R_CHECK(igraph_vector_ptr_init(&%C%, 0)); IGRAPH_FINALLY(R_igraph_sirlist_destroy, &%C%); OUTCONV: OUT: |- @@ -927,7 +824,7 @@ PAGERANKOPT: R_SEXP_to_igraph_arpack_options(%I%, &%C%1); %C% = &%C%1; } else { - %C% = 0; + %C% = NULL; } OUTCONV: INOUT: |-