Skip to content

Commit

Permalink
fix: Fix direction of edges when restoring (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored May 21, 2023
2 parents ed2dc9e + 84fb514 commit bced088
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/rinterface_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -2900,8 +2900,8 @@ void R_igraph_restore_pointer(SEXP graph) {

for (i = 0; i < s; ++i)
{
igraph_vector_set(&v, i*2, VECTOR(to)[i]);
igraph_vector_set(&v, i*2+1, VECTOR(from)[i]);
igraph_vector_set(&v, i*2, VECTOR(from)[i]);
igraph_vector_set(&v, i*2+1, VECTOR(to)[i]);
}

igraph_empty(&g, n, directed);
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/_snaps/plot/basic-graph-r-4-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/testthat/test-serialize.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("serialization works", {
local_igraph_options(print.id = FALSE)

g <- make_ring(3, directed = TRUE)
gs <- unserialize(serialize(g, NULL))

expect_identical(unclass(g)[-igraph_t_idx_env], unclass(gs)[-igraph_t_idx_env])
})

0 comments on commit bced088

Please sign in to comment.