From fc89fcb6f9d4e4d58a880f9f02f8b9a52d1f4378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 18 Apr 2023 17:16:27 +0200 Subject: [PATCH 01/14] igraph_t_idx_max --- R/idx.R | 1 + src/rinterface_extra.c | 26 +++++++++++++++---- .../_snaps/plot/basic-graph-r-4-2.svg | 16 ++++++------ tests/testthat/test-layout.kk.R | 2 ++ tests/testthat/test-versions.R | 2 ++ 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/R/idx.R b/R/idx.R index 330e545eb09..39f2a40005a 100644 --- a/R/idx.R +++ b/R/idx.R @@ -9,6 +9,7 @@ igraph_t_idx_os <- 7L igraph_t_idx_is <- 8L igraph_t_idx_attr <- 9L igraph_t_idx_env <- 10L +igraph_t_idx_max <- 12L # Indexes into unclass(g)[[igraph_t_idx_attr]] igraph_attr_idx_unknown <- 1L # integer of length 3, for what purpose? diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 867aee65387..eca50358fda 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -121,6 +121,22 @@ SEXP R_igraph_0ormatrix_to_SEXP(const igraph_matrix_t *m); SEXP R_igraph_vector_to_SEXPp1(const igraph_vector_t *v); SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); +enum igraph_t_idx { + igraph_t_idx_n, + igraph_t_idx_directed, + igraph_t_idx_from, + igraph_t_idx_to, + igraph_t_idx_oi, + igraph_t_idx_ii, + igraph_t_idx_os, + igraph_t_idx_is, + igraph_t_idx_attr, + + igraph_t_idx_env, + + igraph_t_idx_max = 11, +}; + SEXP R_igraph_i_lang7(SEXP s, SEXP t, SEXP u, SEXP v, SEXP w, SEXP x, SEXP y) { @@ -2844,7 +2860,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { long int no_of_nodes=igraph_vcount(graph); long int no_of_edges=igraph_ecount(graph); - PROTECT(result=NEW_LIST(10)); + PROTECT(result=NEW_LIST(igraph_t_idx_max)); SET_VECTOR_ELT(result, 0, NEW_NUMERIC(1)); SET_VECTOR_ELT(result, 1, NEW_LOGICAL(1)); SET_VECTOR_ELT(result, 2, NEW_NUMERIC(no_of_edges)); @@ -9710,7 +9726,7 @@ SEXP R_igraph_identical_graphs(SEXP g1, SEXP g2, SEXP attrs) { } SEXP R_igraph_graph_version(SEXP graph) { - if (GET_LENGTH(graph) == 10 && Rf_isEnvironment(VECTOR_ELT(graph, 9))) { + if (GET_LENGTH(graph) == igraph_t_idx_max && Rf_isEnvironment(VECTOR_ELT(graph, 9))) { SEXP ver = Rf_findVar(Rf_install(R_IGRAPH_VERSION_VAR), VECTOR_ELT(graph, 9)); if (ver != R_UnboundValue) { return ver; @@ -9750,9 +9766,9 @@ SEXP R_igraph_add_env(SEXP graph) { char my_id_chr[40]; int px = 0; - if (GET_LENGTH(graph) != 10) { - PROTECT(result = NEW_LIST(10)); px++; - for (i = 0; i < 9; i++) { + if (GET_LENGTH(graph) <= igraph_t_idx_env) { + PROTECT(result = NEW_LIST(igraph_t_idx_max)); px++; + for (i = 0; i < igraph_t_idx_env; i++) { SET_VECTOR_ELT(result, i, Rf_duplicate(VECTOR_ELT(graph, i))); } SET_ATTRIB(result, Rf_duplicate(ATTRIB(graph))); diff --git a/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg b/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg index 88eb7423399..fddeb30284f 100644 --- a/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg +++ b/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg @@ -25,16 +25,16 @@ - - - - - + + + + + -1 -2 -3 +1 +2 +3 diff --git a/tests/testthat/test-layout.kk.R b/tests/testthat/test-layout.kk.R index 619568a7abf..42ec64d1799 100644 --- a/tests/testthat/test-layout.kk.R +++ b/tests/testthat/test-layout.kk.R @@ -1,6 +1,8 @@ test_that("Kamada-Kawai layout generator works", { skip_on_cran() + skip("Why does this fail now?") + set.seed(42) get_radii <- function(layout) { diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index 3a2408474a7..f69077fbb16 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -6,6 +6,8 @@ test_that("we create graphs of the current version", { }) test_that("we can upgrade from 0.4.0 to 0.8.0", { + skip("FIXME: upgrades from older versions, add new test too") + g <- make_ring(10) g <- unclass(g) g[[10]] <- NULL From 34fdeb51d5bd370ec7dc9d8051ba6088769f98c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 18 Apr 2023 17:37:08 +0200 Subject: [PATCH 02/14] igraph_t_idx_env --- R/idx.R | 2 +- src/rinterface_extra.c | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/R/idx.R b/R/idx.R index 39f2a40005a..225a1483eea 100644 --- a/R/idx.R +++ b/R/idx.R @@ -8,7 +8,7 @@ igraph_t_idx_ii <- 6L igraph_t_idx_os <- 7L igraph_t_idx_is <- 8L igraph_t_idx_attr <- 9L -igraph_t_idx_env <- 10L +igraph_t_idx_env <- 11L igraph_t_idx_max <- 12L # Indexes into unclass(g)[[igraph_t_idx_attr]] diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index eca50358fda..983f649ee66 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -132,7 +132,7 @@ enum igraph_t_idx { igraph_t_idx_is, igraph_t_idx_attr, - igraph_t_idx_env, + igraph_t_idx_env = 10, igraph_t_idx_max = 11, }; @@ -2892,7 +2892,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { REAL(VECTOR_ELT(graph->attr, 0))[0] += 1; /* Environment for vertex/edge seqs */ - SET_VECTOR_ELT(result, 9, R_NilValue); + SET_VECTOR_ELT(result, igraph_t_idx_env, R_NilValue); R_igraph_add_env(result); UNPROTECT(1); @@ -9725,9 +9725,13 @@ SEXP R_igraph_identical_graphs(SEXP g1, SEXP g2, SEXP attrs) { return Rf_ScalarLogical(1); } +SEXP R_igraph_graph_env(SEXP graph) { + return VECTOR_ELT(graph, igraph_t_idx_env); +} + SEXP R_igraph_graph_version(SEXP graph) { - if (GET_LENGTH(graph) == igraph_t_idx_max && Rf_isEnvironment(VECTOR_ELT(graph, 9))) { - SEXP ver = Rf_findVar(Rf_install(R_IGRAPH_VERSION_VAR), VECTOR_ELT(graph, 9)); + if (GET_LENGTH(graph) == igraph_t_idx_max && Rf_isEnvironment(R_igraph_graph_env(graph))) { + SEXP ver = Rf_findVar(Rf_install(R_IGRAPH_VERSION_VAR), R_igraph_graph_env(graph)); if (ver != R_UnboundValue) { return ver; } else { @@ -9748,11 +9752,11 @@ SEXP R_igraph_add_version_to_env(SEXP graph) { uuid_unparse_lower(my_id, my_id_chr); SEXP l1 = PROTECT(Rf_install("myid")); SEXP l2 = PROTECT(Rf_mkString(my_id_chr)); - Rf_defineVar(l1, l2, VECTOR_ELT(graph, 9)); + Rf_defineVar(l1, l2, R_igraph_graph_env(graph)); UNPROTECT(2); l1 = PROTECT(Rf_install(R_IGRAPH_VERSION_VAR)); l2 = PROTECT(Rf_mkString(R_IGRAPH_TYPE_VERSION)); - Rf_defineVar(l1, l2, VECTOR_ELT(graph, 9)); + Rf_defineVar(l1, l2, R_igraph_graph_env(graph)); UNPROTECT(2); UNPROTECT(1); @@ -9775,18 +9779,18 @@ SEXP R_igraph_add_env(SEXP graph) { SET_CLASS(result, Rf_duplicate(GET_CLASS(graph))); } - SET_VECTOR_ELT(result, 9, Rf_allocSExp(ENVSXP)); + SET_VECTOR_ELT(result, igraph_t_idx_env, Rf_allocSExp(ENVSXP)); uuid_generate(my_id); uuid_unparse_lower(my_id, my_id_chr); SEXP l1 = PROTECT(Rf_install("myid")); px++; SEXP l2 = PROTECT(Rf_mkString(my_id_chr)); px++; - Rf_defineVar(l1, l2, VECTOR_ELT(result, 9)); + Rf_defineVar(l1, l2, R_igraph_graph_env(result)); l1 = PROTECT(Rf_install(R_IGRAPH_VERSION_VAR)); px++; l2 = PROTECT(Rf_mkString(R_IGRAPH_TYPE_VERSION)); px++; - Rf_defineVar(l1, l2, VECTOR_ELT(result, 9)); + Rf_defineVar(l1, l2, R_igraph_graph_env(result)); UNPROTECT(px); @@ -9794,5 +9798,5 @@ SEXP R_igraph_add_env(SEXP graph) { } SEXP R_igraph_get_graph_id(SEXP graph) { - return Rf_findVar(Rf_install("myid"), VECTOR_ELT(graph, 9)); + return Rf_findVar(Rf_install("myid"), R_igraph_graph_env(graph)); } From 714842e4416d86b4e1a504dbdd878fd4e7477ee8 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Wed, 19 Apr 2023 13:39:25 +0200 Subject: [PATCH 03/14] add `igraph_t_idx_attr` --- R/idx.R | 2 +- src/rinterface_extra.c | 20 +++++++++---------- .../_snaps/plot/basic-graph-r-4-2.svg | 16 +++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/R/idx.R b/R/idx.R index 225a1483eea..d1270bf05af 100644 --- a/R/idx.R +++ b/R/idx.R @@ -7,7 +7,7 @@ igraph_t_idx_oi <- 5L igraph_t_idx_ii <- 6L igraph_t_idx_os <- 7L igraph_t_idx_is <- 8L -igraph_t_idx_attr <- 9L +igraph_t_idx_attr <- 10L igraph_t_idx_env <- 11L igraph_t_idx_max <- 12L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 983f649ee66..6f187a50e8a 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -130,7 +130,7 @@ enum igraph_t_idx { igraph_t_idx_ii, igraph_t_idx_os, igraph_t_idx_is, - igraph_t_idx_attr, + igraph_t_idx_attr = 9, igraph_t_idx_env = 10, @@ -269,7 +269,7 @@ SEXP R_igraph_handle_safe_eval_result(SEXP result) { SEXP R_igraph_get_attr_mode(SEXP graph, SEXP pwhich) { int which=INTEGER(pwhich)[0]-1; - SEXP obj=VECTOR_ELT(VECTOR_ELT(graph, 8), which); + SEXP obj=VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), which); int i, len=GET_LENGTH(obj); SEXP result; @@ -2888,7 +2888,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_CLASS(result, Rf_ScalarString(Rf_mkChar("igraph"))); /* Attributes */ - SET_VECTOR_ELT(result, 8, graph->attr); + SET_VECTOR_ELT(result, igraph_t_idx_attr, graph->attr); REAL(VECTOR_ELT(graph->attr, 0))[0] += 1; /* Environment for vertex/edge seqs */ @@ -3505,9 +3505,9 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { R_SEXP_to_vector(VECTOR_ELT(graph, 7), &res->is); /* attributes */ - REAL(VECTOR_ELT(VECTOR_ELT(graph, 8), 0))[0] = 1; /* R objects refcount */ - REAL(VECTOR_ELT(VECTOR_ELT(graph, 8), 0))[1] = 0; /* igraph_t objects */ - res->attr=VECTOR_ELT(graph, 8); + REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[0] = 1; /* R objects refcount */ + REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[1] = 0; /* igraph_t objects */ + res->attr=VECTOR_ELT(graph, igraph_t_idx_attr); return 0; } @@ -3530,9 +3530,9 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { GET_LENGTH(VECTOR_ELT(graph, 7))); /* attributes */ - REAL(VECTOR_ELT(VECTOR_ELT(graph, 8), 0))[0] = 1; /* R objects */ - REAL(VECTOR_ELT(VECTOR_ELT(graph, 8), 0))[1] = 1; /* igraph_t objects */ - R_PreserveObject(res->attr=VECTOR_ELT(graph, 8)); + REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[0] = 1; /* R objects */ + REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[1] = 1; /* igraph_t objects */ + R_PreserveObject(res->attr=VECTOR_ELT(graph, igraph_t_idx_attr)); return 0; } @@ -9716,7 +9716,7 @@ SEXP R_igraph_weak_ref_run_finalizer(SEXP ref) { SEXP R_igraph_identical_graphs(SEXP g1, SEXP g2, SEXP attrs) { int i; - int n = LOGICAL(attrs)[0] ? 9 : 8; + int n = LOGICAL(attrs)[0] ? igraph_t_idx_attr + 1 : igraph_t_idx_attr; for (i = 0; i < n; i++) { if (!R_compute_identical(VECTOR_ELT(g1, i), VECTOR_ELT(g2, i), 0)) { return Rf_ScalarLogical(0); diff --git a/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg b/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg index fddeb30284f..88eb7423399 100644 --- a/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg +++ b/tests/testthat/_snaps/plot/basic-graph-r-4-2.svg @@ -25,16 +25,16 @@ - - - - - + + + + + -1 -2 -3 +1 +2 +3 From 0cac02449953d125b753d19a1104cb50f4e58fc8 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Wed, 19 Apr 2023 14:18:46 +0200 Subject: [PATCH 04/14] add `igraph_t_idx_attr` --- R/glet.R | 2 +- R/idx.R | 2 +- src/rinterface_extra.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/glet.R b/R/glet.R index e8edb9c3057..e1ce4430c40 100644 --- a/R/glet.R +++ b/R/glet.R @@ -94,7 +94,7 @@ graphlet_basis <- function(graph, weights = NULL) { ## Drop all attributes, we don't want to deal with them, TODO graph2 <- graph - graph2[[9]] <- list(c(1, 0, 1), list(), list(), list()) + graph2[[igraph_t_idx_attr]] <- list(c(1, 0, 1), list(), list(), list()) on.exit(.Call(R_igraph_finalizer)) ## Function call diff --git a/R/idx.R b/R/idx.R index d1270bf05af..d4a0415633d 100644 --- a/R/idx.R +++ b/R/idx.R @@ -6,7 +6,7 @@ igraph_t_idx_to <- 4L igraph_t_idx_oi <- 5L igraph_t_idx_ii <- 6L igraph_t_idx_os <- 7L -igraph_t_idx_is <- 8L +igraph_t_idx_is <- 9L igraph_t_idx_attr <- 10L igraph_t_idx_env <- 11L igraph_t_idx_max <- 12L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 6f187a50e8a..e97418441b3 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -129,7 +129,7 @@ enum igraph_t_idx { igraph_t_idx_oi, igraph_t_idx_ii, igraph_t_idx_os, - igraph_t_idx_is, + igraph_t_idx_is = 8, igraph_t_idx_attr = 9, igraph_t_idx_env = 10, @@ -2868,7 +2868,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_VECTOR_ELT(result, 4, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, 5, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, 6, NEW_NUMERIC(no_of_nodes+1)); - SET_VECTOR_ELT(result, 7, NEW_NUMERIC(no_of_nodes+1)); + SET_VECTOR_ELT(result, igraph_t_idx_is, NEW_NUMERIC(no_of_nodes+1)); REAL(VECTOR_ELT(result, 0))[0]=no_of_nodes; LOGICAL(VECTOR_ELT(result, 1))[0]=graph->directed; @@ -2882,7 +2882,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, 6)), graph->os.stor_begin, sizeof(igraph_real_t)*(size_t) (no_of_nodes+1)); - memcpy(REAL(VECTOR_ELT(result, 7)), graph->is.stor_begin, + memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_is)), graph->is.stor_begin, sizeof(igraph_real_t)*(size_t) (no_of_nodes+1)); SET_CLASS(result, Rf_ScalarString(Rf_mkChar("igraph"))); @@ -3502,7 +3502,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { R_SEXP_to_vector(VECTOR_ELT(graph, 4), &res->oi); R_SEXP_to_vector(VECTOR_ELT(graph, 5), &res->ii); R_SEXP_to_vector(VECTOR_ELT(graph, 6), &res->os); - R_SEXP_to_vector(VECTOR_ELT(graph, 7), &res->is); + R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_is), &res->is); /* attributes */ REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[0] = 1; /* R objects refcount */ @@ -3526,8 +3526,8 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { GET_LENGTH(VECTOR_ELT(graph, 5))); igraph_vector_init_copy(&res->os, REAL(VECTOR_ELT(graph, 6)), GET_LENGTH(VECTOR_ELT(graph, 6))); - igraph_vector_init_copy(&res->is, REAL(VECTOR_ELT(graph, 7)), - GET_LENGTH(VECTOR_ELT(graph, 7))); + igraph_vector_init_copy(&res->is, REAL(VECTOR_ELT(graph, igraph_t_idx_is)), + GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_is))); /* attributes */ REAL(VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), 0))[0] = 1; /* R objects */ From 9a6d6865372ef62220d0ce21c511855ff8cd195e Mon Sep 17 00:00:00 2001 From: antonov548 Date: Wed, 19 Apr 2023 14:29:17 +0200 Subject: [PATCH 05/14] add `igraph_t_idx_os` --- R/idx.R | 2 +- src/rinterface_extra.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/idx.R b/R/idx.R index d4a0415633d..6012df55578 100644 --- a/R/idx.R +++ b/R/idx.R @@ -5,7 +5,7 @@ igraph_t_idx_from <- 3L igraph_t_idx_to <- 4L igraph_t_idx_oi <- 5L igraph_t_idx_ii <- 6L -igraph_t_idx_os <- 7L +igraph_t_idx_os <- 8L igraph_t_idx_is <- 9L igraph_t_idx_attr <- 10L igraph_t_idx_env <- 11L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index e97418441b3..667ee108ef6 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -128,7 +128,7 @@ enum igraph_t_idx { igraph_t_idx_to, igraph_t_idx_oi, igraph_t_idx_ii, - igraph_t_idx_os, + igraph_t_idx_os = 7, igraph_t_idx_is = 8, igraph_t_idx_attr = 9, @@ -2867,7 +2867,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_VECTOR_ELT(result, 3, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, 4, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, 5, NEW_NUMERIC(no_of_edges)); - SET_VECTOR_ELT(result, 6, NEW_NUMERIC(no_of_nodes+1)); + SET_VECTOR_ELT(result, igraph_t_idx_os, NEW_NUMERIC(no_of_nodes+1)); SET_VECTOR_ELT(result, igraph_t_idx_is, NEW_NUMERIC(no_of_nodes+1)); REAL(VECTOR_ELT(result, 0))[0]=no_of_nodes; @@ -2880,7 +2880,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, 5)), graph->ii.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 6)), graph->os.stor_begin, + memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_os)), graph->os.stor_begin, sizeof(igraph_real_t)*(size_t) (no_of_nodes+1)); memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_is)), graph->is.stor_begin, sizeof(igraph_real_t)*(size_t) (no_of_nodes+1)); @@ -3501,7 +3501,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { R_SEXP_to_vector(VECTOR_ELT(graph, 3), &res->to); R_SEXP_to_vector(VECTOR_ELT(graph, 4), &res->oi); R_SEXP_to_vector(VECTOR_ELT(graph, 5), &res->ii); - R_SEXP_to_vector(VECTOR_ELT(graph, 6), &res->os); + R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_os), &res->os); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_is), &res->is); /* attributes */ @@ -3524,8 +3524,8 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { GET_LENGTH(VECTOR_ELT(graph, 4))); igraph_vector_init_copy(&res->ii, REAL(VECTOR_ELT(graph, 5)), GET_LENGTH(VECTOR_ELT(graph, 5))); - igraph_vector_init_copy(&res->os, REAL(VECTOR_ELT(graph, 6)), - GET_LENGTH(VECTOR_ELT(graph, 6))); + igraph_vector_init_copy(&res->os, REAL(VECTOR_ELT(graph, igraph_t_idx_os)), + GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_os))); igraph_vector_init_copy(&res->is, REAL(VECTOR_ELT(graph, igraph_t_idx_is)), GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_is))); From f615f756e0415110606135209ecbbd6e93c56cb6 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Wed, 19 Apr 2023 14:57:01 +0200 Subject: [PATCH 06/14] skip test with old data type --- tests/testthat/test-old-data-type.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-old-data-type.R b/tests/testthat/test-old-data-type.R index 684c0fc6f91..525fc7be588 100644 --- a/tests/testthat/test-old-data-type.R +++ b/tests/testthat/test-old-data-type.R @@ -1,4 +1,5 @@ test_that("VS/ES work with old data type", { + skip("Fix update of old graph") karate <- structure( list( From c2c601e303c2f1b78cfd5a577c819f3821f02698 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 18:47:28 +0200 Subject: [PATCH 07/14] add `igraph_t_idx_ii` --- R/idx.R | 2 +- src/rinterface_extra.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/idx.R b/R/idx.R index 6012df55578..731336ae8fb 100644 --- a/R/idx.R +++ b/R/idx.R @@ -4,7 +4,7 @@ igraph_t_idx_directed <- 2L igraph_t_idx_from <- 3L igraph_t_idx_to <- 4L igraph_t_idx_oi <- 5L -igraph_t_idx_ii <- 6L +igraph_t_idx_ii <- 7L igraph_t_idx_os <- 8L igraph_t_idx_is <- 9L igraph_t_idx_attr <- 10L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 667ee108ef6..8abc1fd6c32 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -127,7 +127,7 @@ enum igraph_t_idx { igraph_t_idx_from, igraph_t_idx_to, igraph_t_idx_oi, - igraph_t_idx_ii, + igraph_t_idx_ii = 6, igraph_t_idx_os = 7, igraph_t_idx_is = 8, igraph_t_idx_attr = 9, @@ -2866,7 +2866,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_VECTOR_ELT(result, 2, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, 3, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, 4, NEW_NUMERIC(no_of_edges)); - SET_VECTOR_ELT(result, 5, NEW_NUMERIC(no_of_edges)); + SET_VECTOR_ELT(result, igraph_t_idx_ii, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_os, NEW_NUMERIC(no_of_nodes+1)); SET_VECTOR_ELT(result, igraph_t_idx_is, NEW_NUMERIC(no_of_nodes+1)); @@ -2878,7 +2878,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, 4)), graph->oi.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 5)), graph->ii.stor_begin, + memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_ii)), graph->ii.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_os)), graph->os.stor_begin, sizeof(igraph_real_t)*(size_t) (no_of_nodes+1)); @@ -3500,7 +3500,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { R_SEXP_to_vector(VECTOR_ELT(graph, 2), &res->from); R_SEXP_to_vector(VECTOR_ELT(graph, 3), &res->to); R_SEXP_to_vector(VECTOR_ELT(graph, 4), &res->oi); - R_SEXP_to_vector(VECTOR_ELT(graph, 5), &res->ii); + R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_ii), &res->ii); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_os), &res->os); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_is), &res->is); @@ -3522,8 +3522,8 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { GET_LENGTH(VECTOR_ELT(graph, 3))); igraph_vector_init_copy(&res->oi, REAL(VECTOR_ELT(graph, 4)), GET_LENGTH(VECTOR_ELT(graph, 4))); - igraph_vector_init_copy(&res->ii, REAL(VECTOR_ELT(graph, 5)), - GET_LENGTH(VECTOR_ELT(graph, 5))); + igraph_vector_init_copy(&res->ii, REAL(VECTOR_ELT(graph, igraph_t_idx_ii)), + GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_ii))); igraph_vector_init_copy(&res->os, REAL(VECTOR_ELT(graph, igraph_t_idx_os)), GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_os))); igraph_vector_init_copy(&res->is, REAL(VECTOR_ELT(graph, igraph_t_idx_is)), From cd7a66479a0a585ebb2c9f2949a059643021bba4 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 18:50:50 +0200 Subject: [PATCH 08/14] add `igraph_t_idx_oi` --- R/idx.R | 2 +- src/rinterface_extra.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/idx.R b/R/idx.R index 731336ae8fb..36329d50739 100644 --- a/R/idx.R +++ b/R/idx.R @@ -3,7 +3,7 @@ igraph_t_idx_n <- 1L igraph_t_idx_directed <- 2L igraph_t_idx_from <- 3L igraph_t_idx_to <- 4L -igraph_t_idx_oi <- 5L +igraph_t_idx_oi <- 6L igraph_t_idx_ii <- 7L igraph_t_idx_os <- 8L igraph_t_idx_is <- 9L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 8abc1fd6c32..21938e70407 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -126,7 +126,7 @@ enum igraph_t_idx { igraph_t_idx_directed, igraph_t_idx_from, igraph_t_idx_to, - igraph_t_idx_oi, + igraph_t_idx_oi = 5, igraph_t_idx_ii = 6, igraph_t_idx_os = 7, igraph_t_idx_is = 8, @@ -2865,7 +2865,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_VECTOR_ELT(result, 1, NEW_LOGICAL(1)); SET_VECTOR_ELT(result, 2, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, 3, NEW_NUMERIC(no_of_edges)); - SET_VECTOR_ELT(result, 4, NEW_NUMERIC(no_of_edges)); + SET_VECTOR_ELT(result, igraph_t_idx_oi, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_ii, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_os, NEW_NUMERIC(no_of_nodes+1)); SET_VECTOR_ELT(result, igraph_t_idx_is, NEW_NUMERIC(no_of_nodes+1)); @@ -2876,7 +2876,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, 3)), graph->to.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 4)), graph->oi.stor_begin, + memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_oi)), graph->oi.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_ii)), graph->ii.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); @@ -3499,7 +3499,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; R_SEXP_to_vector(VECTOR_ELT(graph, 2), &res->from); R_SEXP_to_vector(VECTOR_ELT(graph, 3), &res->to); - R_SEXP_to_vector(VECTOR_ELT(graph, 4), &res->oi); + R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_oi), &res->oi); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_ii), &res->ii); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_os), &res->os); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_is), &res->is); @@ -3520,8 +3520,8 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { GET_LENGTH(VECTOR_ELT(graph, 2))); igraph_vector_init_copy(&res->to, REAL(VECTOR_ELT(graph, 3)), GET_LENGTH(VECTOR_ELT(graph, 3))); - igraph_vector_init_copy(&res->oi, REAL(VECTOR_ELT(graph, 4)), - GET_LENGTH(VECTOR_ELT(graph, 4))); + igraph_vector_init_copy(&res->oi, REAL(VECTOR_ELT(graph, igraph_t_idx_oi)), + GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_oi))); igraph_vector_init_copy(&res->ii, REAL(VECTOR_ELT(graph, igraph_t_idx_ii)), GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_ii))); igraph_vector_init_copy(&res->os, REAL(VECTOR_ELT(graph, igraph_t_idx_os)), From b02d24f35230a9e19e03ac673ceae2bdd6bc75de Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 18:58:16 +0200 Subject: [PATCH 09/14] add `igraph_t_idx_to` --- R/idx.R | 2 +- src/rinterface_extra.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/idx.R b/R/idx.R index 36329d50739..a23fb27ccd8 100644 --- a/R/idx.R +++ b/R/idx.R @@ -2,7 +2,7 @@ igraph_t_idx_n <- 1L igraph_t_idx_directed <- 2L igraph_t_idx_from <- 3L -igraph_t_idx_to <- 4L +igraph_t_idx_to <- 5L igraph_t_idx_oi <- 6L igraph_t_idx_ii <- 7L igraph_t_idx_os <- 8L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 21938e70407..a22e2ee2b90 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -125,7 +125,7 @@ enum igraph_t_idx { igraph_t_idx_n, igraph_t_idx_directed, igraph_t_idx_from, - igraph_t_idx_to, + igraph_t_idx_to = 4, igraph_t_idx_oi = 5, igraph_t_idx_ii = 6, igraph_t_idx_os = 7, @@ -2864,7 +2864,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_VECTOR_ELT(result, 0, NEW_NUMERIC(1)); SET_VECTOR_ELT(result, 1, NEW_LOGICAL(1)); SET_VECTOR_ELT(result, 2, NEW_NUMERIC(no_of_edges)); - SET_VECTOR_ELT(result, 3, NEW_NUMERIC(no_of_edges)); + SET_VECTOR_ELT(result, igraph_t_idx_to, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_oi, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_ii, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_os, NEW_NUMERIC(no_of_nodes+1)); @@ -2874,7 +2874,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { LOGICAL(VECTOR_ELT(result, 1))[0]=graph->directed; memcpy(REAL(VECTOR_ELT(result, 2)), graph->from.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 3)), graph->to.stor_begin, + memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_to)), graph->to.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_oi)), graph->oi.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); @@ -3498,7 +3498,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; R_SEXP_to_vector(VECTOR_ELT(graph, 2), &res->from); - R_SEXP_to_vector(VECTOR_ELT(graph, 3), &res->to); + R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_to), &res->to); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_oi), &res->oi); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_ii), &res->ii); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_os), &res->os); @@ -3518,8 +3518,8 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; igraph_vector_init_copy(&res->from, REAL(VECTOR_ELT(graph, 2)), GET_LENGTH(VECTOR_ELT(graph, 2))); - igraph_vector_init_copy(&res->to, REAL(VECTOR_ELT(graph, 3)), - GET_LENGTH(VECTOR_ELT(graph, 3))); + igraph_vector_init_copy(&res->to, REAL(VECTOR_ELT(graph, igraph_t_idx_to)), + GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_to))); igraph_vector_init_copy(&res->oi, REAL(VECTOR_ELT(graph, igraph_t_idx_oi)), GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_oi))); igraph_vector_init_copy(&res->ii, REAL(VECTOR_ELT(graph, igraph_t_idx_ii)), From 48bcef513b3799ce41fbf30f6a12179becd24ff5 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 19:03:57 +0200 Subject: [PATCH 10/14] add `igraph_t_idx_from` --- R/idx.R | 2 +- src/rinterface_extra.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/idx.R b/R/idx.R index a23fb27ccd8..4aa76c35cb3 100644 --- a/R/idx.R +++ b/R/idx.R @@ -1,7 +1,7 @@ # Indexes into unclass(g) igraph_t_idx_n <- 1L igraph_t_idx_directed <- 2L -igraph_t_idx_from <- 3L +igraph_t_idx_from <- 4L igraph_t_idx_to <- 5L igraph_t_idx_oi <- 6L igraph_t_idx_ii <- 7L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index a22e2ee2b90..a6625ca4602 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -124,7 +124,7 @@ SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); enum igraph_t_idx { igraph_t_idx_n, igraph_t_idx_directed, - igraph_t_idx_from, + igraph_t_idx_from = 3, igraph_t_idx_to = 4, igraph_t_idx_oi = 5, igraph_t_idx_ii = 6, @@ -2863,7 +2863,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { PROTECT(result=NEW_LIST(igraph_t_idx_max)); SET_VECTOR_ELT(result, 0, NEW_NUMERIC(1)); SET_VECTOR_ELT(result, 1, NEW_LOGICAL(1)); - SET_VECTOR_ELT(result, 2, NEW_NUMERIC(no_of_edges)); + SET_VECTOR_ELT(result, igraph_t_idx_from, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_to, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_oi, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_ii, NEW_NUMERIC(no_of_edges)); @@ -2872,7 +2872,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { REAL(VECTOR_ELT(result, 0))[0]=no_of_nodes; LOGICAL(VECTOR_ELT(result, 1))[0]=graph->directed; - memcpy(REAL(VECTOR_ELT(result, 2)), graph->from.stor_begin, + memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_from)), graph->from.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_to)), graph->to.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); @@ -3497,7 +3497,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; - R_SEXP_to_vector(VECTOR_ELT(graph, 2), &res->from); + R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_from), &res->from); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_to), &res->to); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_oi), &res->oi); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_ii), &res->ii); @@ -3516,8 +3516,8 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; - igraph_vector_init_copy(&res->from, REAL(VECTOR_ELT(graph, 2)), - GET_LENGTH(VECTOR_ELT(graph, 2))); + igraph_vector_init_copy(&res->from, REAL(VECTOR_ELT(graph, igraph_t_idx_from)), + GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_from))); igraph_vector_init_copy(&res->to, REAL(VECTOR_ELT(graph, igraph_t_idx_to)), GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_to))); igraph_vector_init_copy(&res->oi, REAL(VECTOR_ELT(graph, igraph_t_idx_oi)), From 57daed6436b3479f33171ffea52488ab3a2fa967 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 19:32:35 +0200 Subject: [PATCH 11/14] add `igraph_t_idx_directed` --- R/idx.R | 2 +- src/rinterface_extra.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/idx.R b/R/idx.R index 4aa76c35cb3..a1736a142db 100644 --- a/R/idx.R +++ b/R/idx.R @@ -1,6 +1,6 @@ # Indexes into unclass(g) igraph_t_idx_n <- 1L -igraph_t_idx_directed <- 2L +igraph_t_idx_directed <- 3L igraph_t_idx_from <- 4L igraph_t_idx_to <- 5L igraph_t_idx_oi <- 6L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index a6625ca4602..ba66500d54e 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -123,7 +123,7 @@ SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); enum igraph_t_idx { igraph_t_idx_n, - igraph_t_idx_directed, + igraph_t_idx_directed = 2, igraph_t_idx_from = 3, igraph_t_idx_to = 4, igraph_t_idx_oi = 5, @@ -2862,7 +2862,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { PROTECT(result=NEW_LIST(igraph_t_idx_max)); SET_VECTOR_ELT(result, 0, NEW_NUMERIC(1)); - SET_VECTOR_ELT(result, 1, NEW_LOGICAL(1)); + SET_VECTOR_ELT(result, igraph_t_idx_directed, NEW_LOGICAL(1)); SET_VECTOR_ELT(result, igraph_t_idx_from, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_to, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_oi, NEW_NUMERIC(no_of_edges)); @@ -2871,7 +2871,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_VECTOR_ELT(result, igraph_t_idx_is, NEW_NUMERIC(no_of_nodes+1)); REAL(VECTOR_ELT(result, 0))[0]=no_of_nodes; - LOGICAL(VECTOR_ELT(result, 1))[0]=graph->directed; + LOGICAL(VECTOR_ELT(result, igraph_t_idx_directed))[0]=graph->directed; memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_from)), graph->from.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_to)), graph->to.stor_begin, @@ -3496,7 +3496,7 @@ int R_igraph_SEXP_to_array3_copy(SEXP rval, igraph_array3_t *a) { int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; - res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; + res->directed=LOGICAL(VECTOR_ELT(graph, igraph_t_idx_directed))[0]; R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_from), &res->from); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_to), &res->to); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_oi), &res->oi); @@ -3515,7 +3515,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; - res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; + res->directed=LOGICAL(VECTOR_ELT(graph, igraph_t_idx_directed))[0]; igraph_vector_init_copy(&res->from, REAL(VECTOR_ELT(graph, igraph_t_idx_from)), GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_from))); igraph_vector_init_copy(&res->to, REAL(VECTOR_ELT(graph, igraph_t_idx_to)), From 6222e73a649799aa29c6c9b628072b91d27a610f Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 19:47:58 +0200 Subject: [PATCH 12/14] add `igraph_t_idx_n` --- R/idx.R | 2 +- src/rinterface_extra.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/idx.R b/R/idx.R index a1736a142db..3e897728115 100644 --- a/R/idx.R +++ b/R/idx.R @@ -1,5 +1,5 @@ # Indexes into unclass(g) -igraph_t_idx_n <- 1L +igraph_t_idx_n <- 2L igraph_t_idx_directed <- 3L igraph_t_idx_from <- 4L igraph_t_idx_to <- 5L diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index ba66500d54e..6db8dd8603e 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -122,7 +122,7 @@ SEXP R_igraph_vector_to_SEXPp1(const igraph_vector_t *v); SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); enum igraph_t_idx { - igraph_t_idx_n, + igraph_t_idx_n = 1, igraph_t_idx_directed = 2, igraph_t_idx_from = 3, igraph_t_idx_to = 4, @@ -2861,7 +2861,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { long int no_of_edges=igraph_ecount(graph); PROTECT(result=NEW_LIST(igraph_t_idx_max)); - SET_VECTOR_ELT(result, 0, NEW_NUMERIC(1)); + SET_VECTOR_ELT(result, igraph_t_idx_n, NEW_NUMERIC(1)); SET_VECTOR_ELT(result, igraph_t_idx_directed, NEW_LOGICAL(1)); SET_VECTOR_ELT(result, igraph_t_idx_from, NEW_NUMERIC(no_of_edges)); SET_VECTOR_ELT(result, igraph_t_idx_to, NEW_NUMERIC(no_of_edges)); @@ -2870,7 +2870,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { SET_VECTOR_ELT(result, igraph_t_idx_os, NEW_NUMERIC(no_of_nodes+1)); SET_VECTOR_ELT(result, igraph_t_idx_is, NEW_NUMERIC(no_of_nodes+1)); - REAL(VECTOR_ELT(result, 0))[0]=no_of_nodes; + REAL(VECTOR_ELT(result, igraph_t_idx_n))[0]=no_of_nodes; LOGICAL(VECTOR_ELT(result, igraph_t_idx_directed))[0]=graph->directed; memcpy(REAL(VECTOR_ELT(result, igraph_t_idx_from)), graph->from.stor_begin, sizeof(igraph_real_t)*(size_t) no_of_edges); @@ -3495,7 +3495,7 @@ int R_igraph_SEXP_to_array3_copy(SEXP rval, igraph_array3_t *a) { int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { - res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; + res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, igraph_t_idx_n))[0]; res->directed=LOGICAL(VECTOR_ELT(graph, igraph_t_idx_directed))[0]; R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_from), &res->from); R_SEXP_to_vector(VECTOR_ELT(graph, igraph_t_idx_to), &res->to); @@ -3514,7 +3514,7 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { - res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; + res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, igraph_t_idx_n))[0]; res->directed=LOGICAL(VECTOR_ELT(graph, igraph_t_idx_directed))[0]; igraph_vector_init_copy(&res->from, REAL(VECTOR_ELT(graph, igraph_t_idx_from)), GET_LENGTH(VECTOR_ELT(graph, igraph_t_idx_from))); From bc599c92a8bf6a59167b61723e1842be7b960763 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 19:51:35 +0200 Subject: [PATCH 13/14] update index list --- R/idx.R | 22 +++++++++++----------- src/rinterface_extra.c | 25 +++++++++++-------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/R/idx.R b/R/idx.R index 3e897728115..bd282e277f5 100644 --- a/R/idx.R +++ b/R/idx.R @@ -1,15 +1,15 @@ # Indexes into unclass(g) -igraph_t_idx_n <- 2L -igraph_t_idx_directed <- 3L -igraph_t_idx_from <- 4L -igraph_t_idx_to <- 5L -igraph_t_idx_oi <- 6L -igraph_t_idx_ii <- 7L -igraph_t_idx_os <- 8L -igraph_t_idx_is <- 9L -igraph_t_idx_attr <- 10L -igraph_t_idx_env <- 11L -igraph_t_idx_max <- 12L +igraph_t_idx_n <- 1L +igraph_t_idx_directed <- 2L +igraph_t_idx_from <- 3L +igraph_t_idx_to <- 4L +igraph_t_idx_oi <- 5L +igraph_t_idx_ii <- 6L +igraph_t_idx_os <- 7L +igraph_t_idx_is <- 8L +igraph_t_idx_attr <- 9L +igraph_t_idx_env <- 10L +igraph_t_idx_max <- 11L # Indexes into unclass(g)[[igraph_t_idx_attr]] igraph_attr_idx_unknown <- 1L # integer of length 3, for what purpose? diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 6db8dd8603e..4891b6dcab8 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -122,22 +122,19 @@ SEXP R_igraph_vector_to_SEXPp1(const igraph_vector_t *v); SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); enum igraph_t_idx { - igraph_t_idx_n = 1, - igraph_t_idx_directed = 2, - igraph_t_idx_from = 3, - igraph_t_idx_to = 4, - igraph_t_idx_oi = 5, - igraph_t_idx_ii = 6, - igraph_t_idx_os = 7, - igraph_t_idx_is = 8, - igraph_t_idx_attr = 9, - - igraph_t_idx_env = 10, - - igraph_t_idx_max = 11, + igraph_t_idx_n = 0, + igraph_t_idx_directed = 1, + igraph_t_idx_from = 2, + igraph_t_idx_to = 3, + igraph_t_idx_oi = 4, + igraph_t_idx_ii = 5, + igraph_t_idx_os = 6, + igraph_t_idx_is = 7, + igraph_t_idx_attr = 8, + igraph_t_idx_env = 9, + igraph_t_idx_max = 10, }; - SEXP R_igraph_i_lang7(SEXP s, SEXP t, SEXP u, SEXP v, SEXP w, SEXP x, SEXP y) { PROTECT(s); From cda21d5273c40a54c2970b87f95829c554ae3323 Mon Sep 17 00:00:00 2001 From: antonov548 Date: Thu, 20 Apr 2023 20:12:08 +0200 Subject: [PATCH 14/14] unskip tests --- tests/testthat/test-layout.kk.R | 2 -- tests/testthat/test-old-data-type.R | 1 - tests/testthat/test-versions.R | 2 -- 3 files changed, 5 deletions(-) diff --git a/tests/testthat/test-layout.kk.R b/tests/testthat/test-layout.kk.R index 42ec64d1799..619568a7abf 100644 --- a/tests/testthat/test-layout.kk.R +++ b/tests/testthat/test-layout.kk.R @@ -1,8 +1,6 @@ test_that("Kamada-Kawai layout generator works", { skip_on_cran() - skip("Why does this fail now?") - set.seed(42) get_radii <- function(layout) { diff --git a/tests/testthat/test-old-data-type.R b/tests/testthat/test-old-data-type.R index 525fc7be588..684c0fc6f91 100644 --- a/tests/testthat/test-old-data-type.R +++ b/tests/testthat/test-old-data-type.R @@ -1,5 +1,4 @@ test_that("VS/ES work with old data type", { - skip("Fix update of old graph") karate <- structure( list( diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index f69077fbb16..3a2408474a7 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -6,8 +6,6 @@ test_that("we create graphs of the current version", { }) test_that("we can upgrade from 0.4.0 to 0.8.0", { - skip("FIXME: upgrades from older versions, add new test too") - g <- make_ring(10) g <- unclass(g) g[[10]] <- NULL