Skip to content

Commit c97f506

Browse files
authored
Merge branch 'main' into fix/protect
2 parents b5e46cb + 3ca0b2f commit c97f506

File tree

3 files changed

+69
-50
lines changed

3 files changed

+69
-50
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: igraph
2-
Version: 2.0.3.9020
2+
Version: 2.0.3.9021
33
Title: Network Analysis and Visualization
44
Authors@R: c(
55
person("Gábor", "Csárdi", , "[email protected]", role = "aut",

NEWS.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->
22

3+
# igraph 2.0.3.9021
4+
5+
## Testing
6+
7+
- Improve attribute tests (#1381).
8+
9+
310
# igraph 2.0.3.9020
411

512
## Features

tests/testthat/test-operators.R

+61-49
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,62 @@
1-
test_that("operators work", {
2-
o <- function(x) x[order(x[, 1], x[, 2]), ]
1+
test_that("union() works", {
2+
order_by_two_first_columns <- function(x) x[order(x[, 1], x[, 2]), ]
33

44
g1 <- make_ring(10)
55
g2 <- make_star(11, center = 11, mode = "undirected")
66
gu <- union(g1, g2)
7-
expect_that(vcount(gu), equals(11))
8-
expect_that(ecount(gu), equals(20))
9-
expect_that(
10-
o(rbind(as_edgelist(g1), as_edgelist(g2))),
11-
equals(o(as_edgelist(gu)))
7+
8+
expect_equal(vcount(gu), 11)
9+
expect_equal(ecount(gu), 20)
10+
expect_equal(
11+
order_by_two_first_columns(rbind(as_edgelist(g1), as_edgelist(g2))),
12+
order_by_two_first_columns(as_edgelist(gu))
1213
)
14+
expect_isomorphic(difference(gu, g1), g2)
15+
expect_isomorphic(intersection(gu, g2), g2)
16+
})
1317

18+
test_that("disjoint_union() works", {
19+
order_by_two_first_columns <- function(x) x[order(x[, 1], x[, 2]), ]
20+
21+
g1 <- make_ring(10)
22+
g2 <- make_star(11, center = 11, mode = "undirected")
1423
gdu <- disjoint_union(g1, g2)
15-
expect_that(
16-
o(as_edgelist(gdu)),
17-
equals(o(rbind(
24+
expect_equal(
25+
order_by_two_first_columns(as_edgelist(gdu)),
26+
order_by_two_first_columns(rbind(
1827
as_edgelist(g1),
1928
as_edgelist(g2) + vcount(g1)
20-
)))
29+
))
2130
)
31+
})
2232

23-
####
24-
25-
expect_isomorphic(difference(gu, g1), g2)
26-
27-
####
33+
test_that("intersection() works", {
2834

29-
expect_isomorphic(intersection(gu, g2), g2)
35+
g1 <- make_ring(10)
36+
g2 <- make_star(11, center = 11, mode = "undirected")
37+
gu <- union(g1, g2)
3038

31-
expect_isomorphic(
32-
intersection(gu, g1,
33-
keep.all.vertices = FALSE
34-
),
35-
g1
36-
)
39+
expect_isomorphic(intersection(gu, g1, keep.all.vertices = FALSE), g1)
40+
})
3741

38-
####
42+
test_that("complementer() works", {
43+
g2 <- make_star(11, center = 11, mode = "undirected")
3944

4045
x <- complementer(complementer(g2))
4146
expect_true(identical_graphs(x, g2))
4247

43-
####
48+
})
49+
50+
test_that("compose() works", {
51+
52+
g1 <- make_ring(10)
53+
g2 <- make_star(11, center = 11, mode = "undirected")
54+
gu <- union(g1, g2)
4455

4556
gc <- compose(gu, g1)
46-
expect_that(vcount(gc), equals(11))
47-
expect_that(ecount(gc), equals(60))
48-
expect_that(diameter(gc), equals(2))
57+
expect_equal(vcount(gc), 11)
58+
expect_equal(ecount(gc), 60)
59+
expect_equal(diameter(gc), 2)
4960
})
5061

5162
test_that("Union of directed named graphs", {
@@ -62,34 +73,35 @@ test_that("Union of directed named graphs", {
6273
})
6374

6475
test_that("edge reversal works", {
65-
# directed graph
66-
g <- make_graph(~ 1 -+ 2, 1 -+ 3, 1 -+ 4, 2 -+ 3, 3 -+ 4)
67-
g2 <- reverse_edges(g, 1:3)
76+
directed_graph <- make_graph(~ 1 -+ 2, 1 -+ 3, 1 -+ 4, 2 -+ 3, 3 -+ 4)
77+
reverse_directed_graph <- reverse_edges(directed_graph, 1:3)
6878
expected <- make_graph(~ 1 +- 2, 1 +- 3, 1 +- 4, 2 -+ 3, 3 -+ 4)
69-
expect_true(isomorphic(g2, expected))
79+
expect_true(isomorphic(reverse_directed_graph, expected))
7080

71-
# undirected graph
72-
g <- make_graph(~ 1 -- 2, 1 -- 3, 1 -- 4, 2 -- 3, 3 -- 4)
73-
g2 <- reverse_edges(g, 1:3)
74-
expect_true(identical_graphs(g, g2))
81+
reverse_all_directed_graph <- reverse_edges(directed_graph)
82+
expect_equal(vcount(reverse_all_directed_graph), vcount(directed_graph))
83+
expect_equal(
84+
as_edgelist(reverse_all_directed_graph),
85+
as_edgelist(directed_graph)[, c(2, 1)]
86+
)
7587

76-
# all edges
77-
g <- make_graph(~ 1 -+ 2, 1 -+ 3, 1 -+ 4, 2 -+ 3, 3 -+ 4)
78-
g2 <- reverse_edges(g)
79-
expect_that(vcount(g2), equals(vcount(g)))
80-
expect_that(as_edgelist(g2), equals(as_edgelist(g)[, c(2, 1)]))
81-
82-
# graph with isolated vertices
83-
g <- make_graph(~ 1:2:3:4:5, 1 -+ 2, 1 -+ 4)
84-
g2 <- reverse_edges(g)
85-
expect_that(vcount(g2), equals(vcount(g)))
86-
expect_that(as_edgelist(g2), equals(as_edgelist(g)[, c(2, 1)]))
88+
undirected_graph <- make_graph(~ 1 -- 2, 1 -- 3, 1 -- 4, 2 -- 3, 3 -- 4)
89+
reverse_undirected_graph <- reverse_edges(undirected_graph, 1:3)
90+
expect_true(identical_graphs(undirected_graph, reverse_undirected_graph))
91+
92+
isolated_vertices_g <- make_graph(~ 1:2:3:4:5, 1 -+ 2, 1 -+ 4)
93+
reverse_isolated_vertices_g <- reverse_edges(isolated_vertices_g)
94+
expect_equal(vcount(reverse_isolated_vertices_g), vcount(isolated_vertices_g))
95+
expect_equal(
96+
as_edgelist(reverse_isolated_vertices_g),
97+
as_edgelist(isolated_vertices_g)[, c(2, 1)]
98+
)
8799
})
88100

89101
test_that("t() is aliased to edge reversal for graphs", {
90102
g <- make_graph(~ 1 -+ 2, 1 -+ 3, 1 -+ 4, 2 -+ 3, 3 -+ 4)
91-
expect_that(vcount(t(g)), equals(vcount(g)))
92-
expect_that(as_edgelist(t(g)), equals(as_edgelist(g)[, c(2, 1)]))
103+
expect_equal(vcount(t(g)), vcount(g))
104+
expect_equal(as_edgelist(t(g)), as_edgelist(g)[, c(2, 1)])
93105
})
94106

95107
test_that("vertices() works", {

0 commit comments

Comments
 (0)