diff --git a/R/make.R b/R/make.R index 944ad66b39e..be7a5a0936c 100644 --- a/R/make.R +++ b/R/make.R @@ -13,7 +13,7 @@ graph <- function( ..., n = max(edges), isolates = NULL, - directed = TRUE, + directed = FALSE, dir = directed, simplify = TRUE ) { @@ -97,9 +97,7 @@ graph <- function( if (!missing(n)) { args <- c(args, list(n = n)) } - if (!missing(directed)) { - args <- c(args, list(directed = directed)) - } + args <- c(args, list(directed = directed)) do.call(old_graph, args) } else if (is.character(edges)) { @@ -222,9 +220,7 @@ graph.famous <- function( if (!missing(n)) { args <- c(args, list(n = n)) } - if (!missing(directed)) { - args <- c(args, list(directed = directed)) - } + args <- c(args, list(directed = directed)) do.call(old_graph, args) } else if (is.character(edges)) { @@ -309,7 +305,7 @@ graph.ring <- function(n, directed = FALSE, mutual = FALSE, circular = TRUE) { #' @inheritParams make_tree #' @keywords internal #' @export -graph.tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { +graph.tree <- function(n, children = 2, mode = c("undirected", "out", "in")) { # nocov start lifecycle::deprecate_warn("2.1.0", "graph.tree()", "make_tree()") mode <- igraph_match_arg(mode) @@ -339,7 +335,7 @@ graph.tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { #' @export graph.star <- function( n, - mode = c("in", "out", "mutual", "undirected"), + mode = c("undirected", "in", "out", "mutual"), center = 1 ) { # nocov start @@ -1429,7 +1425,7 @@ make_graph <- function( ..., n = max(edges), isolates = NULL, - directed = TRUE, + directed = FALSE, dir = directed, simplify = TRUE ) { @@ -1511,9 +1507,7 @@ make_graph <- function( if (!missing(n)) { args <- c(args, list(n = n)) } - if (!missing(directed)) { - args <- c(args, list(directed = directed)) - } + args <- c(args, list(directed = directed)) do.call(old_graph, args) } else if (is.character(edges)) { @@ -1926,7 +1920,7 @@ from_literal <- function(...) { make_star <- function( n, ..., - mode = c("in", "out", "mutual", "undirected"), + mode = c("undirected", "in", "out", "mutual"), center = 1 ) { # BEGIN GENERATED ARG_HANDLE: make_star, do not edit, see tools/generate-migrations.R @@ -1939,7 +1933,7 @@ make_star <- function( match_names = c("mode", "center"), match_to = c("mode", "center"), defaults = list( - mode = c("in", "out", "mutual", "undirected"), + mode = c("undirected", "in", "out", "mutual"), center = 1 ), head_args = c("n"), @@ -2407,7 +2401,7 @@ make_tree <- function( n, children = 2, ..., - mode = c("out", "in", "undirected") + mode = c("undirected", "out", "in") ) { # BEGIN GENERATED ARG_HANDLE: make_tree, do not edit, see tools/generate-migrations.R if (...length() > 0L) { @@ -2418,7 +2412,7 @@ make_tree <- function( recover_old = c("mode"), match_names = c("mode"), match_to = c("mode"), - defaults = list(mode = c("out", "in", "undirected")), + defaults = list(mode = c("undirected", "out", "in")), head_args = c("n", "children"), fn_name = "make_tree" ) diff --git a/man/graph.Rd b/man/graph.Rd index 1502dd379af..5780d4fc30f 100644 --- a/man/graph.Rd +++ b/man/graph.Rd @@ -9,7 +9,7 @@ graph( ..., n = max(edges), isolates = NULL, - directed = TRUE, + directed = FALSE, dir = directed, simplify = TRUE ) diff --git a/man/graph.star.Rd b/man/graph.star.Rd index 40d33ca94b6..740e0503fea 100644 --- a/man/graph.star.Rd +++ b/man/graph.star.Rd @@ -4,7 +4,7 @@ \alias{graph.star} \title{Create a star graph, a tree with n vertices and n - 1 leaves} \usage{ -graph.star(n, mode = c("in", "out", "mutual", "undirected"), center = 1) +graph.star(n, mode = c("undirected", "in", "out", "mutual"), center = 1) } \arguments{ \item{n}{Number of vertices.} diff --git a/man/graph.tree.Rd b/man/graph.tree.Rd index 754ef310199..e79e55dc0cb 100644 --- a/man/graph.tree.Rd +++ b/man/graph.tree.Rd @@ -4,7 +4,7 @@ \alias{graph.tree} \title{Create tree graphs} \usage{ -graph.tree(n, children = 2, mode = c("out", "in", "undirected")) +graph.tree(n, children = 2, mode = c("undirected", "out", "in")) } \arguments{ \item{n}{Number of vertices.} diff --git a/man/make_graph.Rd b/man/make_graph.Rd index 37c8cb01f0d..b55db7b5e71 100644 --- a/man/make_graph.Rd +++ b/man/make_graph.Rd @@ -14,7 +14,7 @@ make_graph( ..., n = max(edges), isolates = NULL, - directed = TRUE, + directed = FALSE, dir = directed, simplify = TRUE ) diff --git a/man/make_star.Rd b/man/make_star.Rd index 059ee69bd5e..8f6e176b10c 100644 --- a/man/make_star.Rd +++ b/man/make_star.Rd @@ -5,7 +5,7 @@ \alias{star} \title{Create a star graph, a tree with n vertices and n - 1 leaves} \usage{ -make_star(n, ..., mode = c("in", "out", "mutual", "undirected"), center = 1) +make_star(n, ..., mode = c("undirected", "in", "out", "mutual"), center = 1) star(n, ..., mode = c("in", "out", "mutual", "undirected"), center = 1) } diff --git a/man/make_tree.Rd b/man/make_tree.Rd index 180c70e9e52..6298cd4ff02 100644 --- a/man/make_tree.Rd +++ b/man/make_tree.Rd @@ -5,7 +5,7 @@ \alias{tree} \title{Create tree graphs} \usage{ -make_tree(n, children = 2, ..., mode = c("out", "in", "undirected")) +make_tree(n, children = 2, ..., mode = c("undirected", "out", "in")) tree(...) } diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index b8315efdb62..19aa6a9ab25 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -10523,9 +10523,9 @@ union_impl(left = g1, right = g2) Output $res - IGRAPH D--- 4 4 -- + IGRAPH U--- 4 4 -- + edges: - [1] 1->2 1->3 2->3 3->4 + [1] 1--2 1--3 2--3 3--4 $edge_map_left [1] 1 3 @@ -10548,9 +10548,9 @@ intersection_impl(left = g1, right = g2) Output $res - IGRAPH D--- 3 2 -- + IGRAPH U--- 3 2 -- + edges: - [1] 1->2 2->3 + [1] 1--2 2--3 $edge_map_left [1] 1 2 diff --git a/tests/testthat/_snaps/conversion.md b/tests/testthat/_snaps/conversion.md index dd796ca286b..261bc653290 100644 --- a/tests/testthat/_snaps/conversion.md +++ b/tests/testthat/_snaps/conversion.md @@ -358,9 +358,9 @@ Output 3 x 3 sparse Matrix of class "dgCMatrix" - [1,] . 2.1 3.2 - [2,] 2.1 . 4.3 - [3,] 3.2 4.3 . + [1,] . 2.1 4.3 + [2,] 2.1 . 3.2 + [3,] 4.3 3.2 . --- @@ -369,8 +369,8 @@ Output 3 x 3 sparse Matrix of class "dgCMatrix" - [1,] . 2.1 3.2 - [2,] . . 4.3 + [1,] . 2.1 4.3 + [2,] . . 3.2 [3,] . . . --- @@ -382,7 +382,7 @@ [1,] . . . [2,] 2.1 . . - [3,] 3.2 4.3 . + [3,] 4.3 3.2 . --- @@ -391,9 +391,9 @@ Output 3 x 3 sparse Matrix of class "dgCMatrix" - [1,] . 2.1 3.2 - [2,] 2.1 . 4.3 - [3,] 3.2 4.3 . + [1,] . 2.1 4.3 + [2,] 2.1 . 3.2 + [3,] 4.3 3.2 . --- @@ -401,9 +401,9 @@ as_adjacency_matrix(g_undir_wt, weights = "weight", sparse = FALSE) Output [,1] [,2] [,3] - [1,] 0.0 2.1 3.2 - [2,] 2.1 0.0 4.3 - [3,] 3.2 4.3 0.0 + [1,] 0.0 2.1 4.3 + [2,] 2.1 0.0 3.2 + [3,] 4.3 3.2 0.0 --- @@ -411,8 +411,8 @@ as_adjacency_matrix(g_undir_wt, weights = "weight", type = "upper", sparse = FALSE) Output [,1] [,2] [,3] - [1,] 0 2.1 3.2 - [2,] 0 0.0 4.3 + [1,] 0 2.1 4.3 + [2,] 0 0.0 3.2 [3,] 0 0.0 0.0 --- @@ -423,7 +423,7 @@ [,1] [,2] [,3] [1,] 0.0 0.0 0 [2,] 2.1 0.0 0 - [3,] 3.2 4.3 0 + [3,] 4.3 3.2 0 --- @@ -431,9 +431,9 @@ as_adjacency_matrix(g_undir_wt, weights = "weight", type = "both", sparse = FALSE) Output [,1] [,2] [,3] - [1,] 0.0 2.1 3.2 - [2,] 2.1 0.0 4.3 - [3,] 3.2 4.3 0.0 + [1,] 0.0 2.1 4.3 + [2,] 2.1 0.0 3.2 + [3,] 4.3 3.2 0.0 --- diff --git a/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg b/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg index 3298e4a90fd..9197c01d6af 100644 --- a/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg +++ b/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg @@ -25,16 +25,11 @@ - - - - - - - - - - + + + + + diff --git a/tests/testthat/_snaps/plot/rectangle-edges.svg b/tests/testthat/_snaps/plot/rectangle-edges.svg index 011a8cf4221..6be823708d1 100644 --- a/tests/testthat/_snaps/plot/rectangle-edges.svg +++ b/tests/testthat/_snaps/plot/rectangle-edges.svg @@ -25,22 +25,14 @@ - - - - - - - - - - - - - - - - + + + + + + + + diff --git a/tests/testthat/helper-indexing.R b/tests/testthat/helper-indexing.R index 08a035a1406..f56f24266f6 100644 --- a/tests/testthat/helper-indexing.R +++ b/tests/testthat/helper-indexing.R @@ -10,13 +10,13 @@ as_unnamed_dense_matrix <- function(x) { } make_test_named_tree <- function() { - g <- make_tree(20) + g <- make_tree(20, mode = "out") V(g)$name <- letters[1:vcount(g)] g } make_test_weighted_tree <- function() { - g <- make_tree(20) + g <- make_tree(20, mode = "out") V(g)$name <- letters[1:vcount(g)] el <- as_edgelist(g, names = FALSE) E(g)$weight <- el[, 1] * el[, 2] diff --git a/tests/testthat/test-aaa-auto.R b/tests/testthat/test-aaa-auto.R index f55d16dea98..1104e2146ed 100644 --- a/tests/testthat/test-aaa-auto.R +++ b/tests/testthat/test-aaa-auto.R @@ -6426,7 +6426,7 @@ test_that("hrg_predict_impl errors", { test_that("hrg_create_impl basic", { igraph_local_seed(20250909) - g <- make_tree(5) + g <- make_tree(5, mode = "out") expect_snapshot(hrg_create_impl( graph = g, prob = rep(0.5, 2) diff --git a/tests/testthat/test-attributes.R b/tests/testthat/test-attributes.R index f46f03db367..71770f7d0c9 100644 --- a/tests/testthat/test-attributes.R +++ b/tests/testthat/test-attributes.R @@ -211,7 +211,7 @@ test_that("cannot use vs/es from another graph", { }) test_that("attribute combinations handle errors correctly", { - g <- make_graph(c(1, 2, 2, 1)) + g <- make_graph(c(1, 2, 2, 1), directed = TRUE) E(g)$weight <- c("a", "b") expect_error( as_undirected(g, edge.attr.comb = list(weight = "sum")), diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index b7abe50bec2..b5491e220a7 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -606,29 +606,29 @@ test_that("eigen_centrality() works", { }) test_that("dense alpha_centrality() works", { - g.1 <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5)) + g.1 <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5), directed = TRUE) ac1 <- alpha_centrality(g.1, sparse = FALSE) expect_equal(ac1, c(1, 1, 3, 4, 5)) - g.2 <- make_graph(c(2, 1, 3, 1, 4, 1, 5, 1)) + g.2 <- make_graph(c(2, 1, 3, 1, 4, 1, 5, 1), directed = TRUE) ac2 <- alpha_centrality(g.2, sparse = FALSE) expect_equal(ac2, c(5, 1, 1, 1, 1)) - g.3 <- make_graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1)) + g.3 <- make_graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1), directed = TRUE) ac3 <- alpha_centrality(g.3, alpha = 0.5, sparse = FALSE) expect_equal(ac3, c(76, 68, 64, 62, 30) / 30) }) test_that("sparse alpha_centrality() works", { - g.1 <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5)) + g.1 <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5), directed = TRUE) ac1 <- alpha_centrality(g.1, sparse = TRUE) expect_equal(ac1, c(1, 1, 3, 4, 5)) - g.2 <- make_graph(c(2, 1, 3, 1, 4, 1, 5, 1)) + g.2 <- make_graph(c(2, 1, 3, 1, 4, 1, 5, 1), directed = TRUE) ac2 <- alpha_centrality(g.2, sparse = TRUE) expect_equal(ac2, c(5, 1, 1, 1, 1)) - g.3 <- make_graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1)) + g.3 <- make_graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1), directed = TRUE) ac3 <- alpha_centrality(g.3, alpha = 0.5, sparse = TRUE) expect_equal(ac3, c(76, 68, 64, 62, 30) / 30) }) @@ -638,7 +638,7 @@ test_that("sparse alpha_centrality() works", { test_that("weighted dense alpha_centrality() works", { igraph_local_seed(42) - star <- make_star(10) + star <- make_star(10, mode = "in") E(star)$weight <- sample(ecount(star)) ac1 <- alpha_centrality(star, sparse = FALSE) @@ -653,7 +653,7 @@ test_that("weighted dense alpha_centrality() works", { test_that("weighted sparse alpha_centrality() works", { igraph_local_seed(42) - star <- make_star(10) + star <- make_star(10, mode = "in") E(star)$weight <- sample(ecount(star)) ac1 <- alpha_centrality(star, sparse = TRUE) @@ -668,7 +668,7 @@ test_that("weighted sparse alpha_centrality() works", { test_that("alpha_centrality() works with custom weight attribute names", { igraph_local_seed(42) - star <- make_star(10) + star <- make_star(10, mode = "in") E(star)$myweight <- sample(ecount(star)) # Test sparse version with custom attribute name @@ -1217,7 +1217,7 @@ test_that("power_centrality() covers migrated tail args and positional recovery" test_that("alpha_centrality() covers migrated tail args and positional recovery", { rlang::local_options(lifecycle_verbosity = "warning") # A small DAG with a loop on vertex 3 and a decoy weight attribute. - dag <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5, 3, 3)) + dag <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5, 3, 3), directed = TRUE) E(dag)$weight <- rep(7, 5) base <- alpha_centrality( diff --git a/tests/testthat/test-flow.R b/tests/testthat/test-flow.R index 35f4f948805..96c586c28eb 100644 --- a/tests/testthat/test-flow.R +++ b/tests/testthat/test-flow.R @@ -1,5 +1,5 @@ test_that("min_cut() works -- value.only=FALSE", { - g_twosquares <- make_graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1)) + g_twosquares <- make_graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1), directed = TRUE) E(g_twosquares)$capacity <- c(3, 1, 2, 10, 1, 3, 2) mc <- min_cut(g_twosquares, value.only = FALSE) @@ -10,7 +10,7 @@ test_that("min_cut() works -- value.only=FALSE", { }) test_that("min_cut() works -- value.only=TRUE", { - g_twosquares <- make_graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1)) + g_twosquares <- make_graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1), directed = TRUE) E(g_twosquares)$capacity <- c(3, 1, 2, 10, 1, 3, 2) mc <- min_cut(g_twosquares, value.only = TRUE) @@ -18,7 +18,7 @@ test_that("min_cut() works -- value.only=TRUE", { }) test_that("min_cut() works -- value.only=FALSE source/target", { - g_twosquares <- make_graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1)) + g_twosquares <- make_graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1), directed = TRUE) E(g_twosquares)$capacity <- c(3, 1, 2, 10, 1, 3, 2) mc <- min_cut(g_twosquares, source = 1, target = 4, value.only = FALSE) diff --git a/tests/testthat/test-games.R b/tests/testthat/test-games.R index f2034ffd21e..c0f0b4004bc 100644 --- a/tests/testthat/test-games.R +++ b/tests/testthat/test-games.R @@ -354,14 +354,19 @@ test_that("sample_pa can start from a graph", { is_degree_two_or_three <- (degree(g_pa1) %in% 2:3) expect_true(sum(is_degree_two_or_three) %in% 0:4) - g_pa2 <- sample_pa(10, m = 1, algorithm = "bag", start.graph = make_star(10)) - expect_isomorphic(g_pa2, make_star(10)) + g_pa2 <- sample_pa( + 10, + m = 1, + algorithm = "bag", + start.graph = make_star(10, mode = "in") + ) + expect_isomorphic(g_pa2, make_star(10, mode = "in")) g_pa3 <- sample_pa( 10, m = 3, algorithm = "psumtree-multiple", - start.graph = make_empty_graph(5) + start.graph = make_empty_graph(5, directed = TRUE) ) expect_equal(degree(g_pa3, mode = "out"), c(0, 0, 0, 0, 0, 3, 3, 3, 3, 3)) @@ -369,28 +374,32 @@ test_that("sample_pa can start from a graph", { 10, m = 3, algorithm = "psumtree-multiple", - start.graph = make_star(5) + start.graph = make_star(5, mode = "in") ) expect_equal(degree(g_pa4, mode = "out"), c(0, 1, 1, 1, 1, 3, 3, 3, 3, 3)) - expect_isomorphic(induced_subgraph(g_pa4, 1:5), make_star(5)) + expect_isomorphic(induced_subgraph(g_pa4, 1:5), make_star(5, mode = "in")) g_pa5 <- sample_pa( 10, m = 3, algorithm = "psumtree-multiple", - start.graph = make_star(10) + start.graph = make_star(10, mode = "in") ) - expect_isomorphic(g_pa5, make_star(10)) + expect_isomorphic(g_pa5, make_star(10, mode = "in")) - g_pa6 <- sample_pa(10, m = 3, start.graph = make_empty_graph(5)) + g_pa6 <- sample_pa( + 10, + m = 3, + start.graph = make_empty_graph(5, directed = TRUE) + ) expect_equal(degree(g_pa6, mode = "out"), c(0, 0, 0, 0, 0, 3, 3, 3, 3, 3)) - g_pa7 <- sample_pa(10, m = 3, start.graph = make_star(5)) + g_pa7 <- sample_pa(10, m = 3, start.graph = make_star(5, mode = "in")) expect_equal(degree(g_pa7, mode = "out"), c(0, 1, 1, 1, 1, 3, 3, 3, 3, 3)) - expect_isomorphic(induced_subgraph(g_pa7, 1:5), make_star(5)) + expect_isomorphic(induced_subgraph(g_pa7, 1:5), make_star(5, mode = "in")) - g_pa8 <- sample_pa(10, m = 3, start.graph = make_star(10)) - expect_isomorphic(g_pa8, make_star(10)) + g_pa8 <- sample_pa(10, m = 3, start.graph = make_star(10, mode = "in")) + expect_isomorphic(g_pa8, make_star(10, mode = "in")) }) test_that("sample_bipartite works -- undirected gnp", { diff --git a/tests/testthat/test-indexing.R b/tests/testthat/test-indexing.R index c11da9ec52d..0699c09a478 100644 --- a/tests/testthat/test-indexing.R +++ b/tests/testthat/test-indexing.R @@ -1,6 +1,6 @@ test_that("[ indexing works", { skip_if_not_installed("Matrix", minimum_version = "1.6.0") - g <- make_tree(20) + g <- make_tree(20, mode = "out") expect_equal(g[1, 2], 1) expect_equal( diff --git a/tests/testthat/test-make.R b/tests/testthat/test-make.R index 64ed052854a..4c93bb41ef7 100644 --- a/tests/testthat/test-make.R +++ b/tests/testthat/test-make.R @@ -226,13 +226,13 @@ test_that("make_lattice prints a warning for fractional length)", { test_that("make_graph works", { graph_make <- make_graph(1:10) - graph_elist <- make_empty_graph(n = 10) + edges(1:10) + graph_elist <- make_empty_graph(n = 10, directed = FALSE) + edges(1:10) expect_identical_graphs(graph_make, graph_elist) }) test_that("make_graph accepts an empty vector or NULL", { graph_make <- make_graph(c()) - graph_empty <- make_empty_graph(n = 0) + graph_empty <- make_empty_graph(n = 0, directed = FALSE) expect_identical_graphs(graph_make, graph_empty) graph_make_null <- make_graph(NULL, n = 0) @@ -244,13 +244,13 @@ test_that("make_graph accepts an empty vector or NULL", { test_that("make_graph works for numeric edges and isolates", { graph_make <- make_graph(1:10, n = 20) - graph_elist <- make_empty_graph(n = 20) + edges(1:10) + graph_elist <- make_empty_graph(n = 20, directed = FALSE) + edges(1:10) expect_identical_graphs(graph_make, graph_elist) }) test_that("make_graph handles names", { graph_make_names <- make_graph(letters[1:10]) - graph_elist_names <- make_empty_graph() + + graph_elist_names <- make_empty_graph(directed = FALSE) + vertices(letters[1:10]) + edges(letters[1:10]) expect_identical_graphs(graph_make_names, graph_elist_names) @@ -258,7 +258,7 @@ test_that("make_graph handles names", { test_that("make_graph handles names and isolates", { graph_make_iso <- make_graph(letters[1:10], isolates = letters[11:20]) - graph_elist_iso <- make_empty_graph() + + graph_elist_iso <- make_empty_graph(directed = FALSE) + vertices(letters[1:20]) + edges(letters[1:10]) expect_identical_graphs(graph_make_iso, graph_elist_iso) @@ -279,7 +279,7 @@ test_that("compatibility when arguments are not named", { # Commit: eb46e5bb252e80780cf3c7f02ca44a57e7469752 elist <- cbind(1, 3) nodes <- 3 - graph_unnamed_args <- make_graph(as.vector(t(elist)), nodes, FALSE) + graph_unnamed_args <- make_graph(as.vector(t(elist)), n = nodes, directed = FALSE) expect_vcount(graph_unnamed_args, 3) expect_ecount(graph_unnamed_args, 1) @@ -360,7 +360,7 @@ test_that("make_de_bruijn_graph works", { make_graph(c( 1, 1, 3, 1, 1, 2, 3, 2, 2, 3, 4, 3, 2, 4, 4, 4 - )) + ), directed = TRUE) ) expect_isomorphic(de_bruijn22, de_bruijn21_line) }) @@ -560,6 +560,39 @@ test_that("make_turan() works", { expect_vcount(g5, 10) }) +test_that("make_tree() defaults to undirected", { + g <- make_tree(10) + expect_false(is_directed(g)) + + # Can still create directed trees + g_out <- make_tree(10, mode = "out") + expect_true(is_directed(g_out)) + + g_in <- make_tree(10, mode = "in") + expect_true(is_directed(g_in)) +}) + +test_that("make_star() defaults to undirected", { + g <- make_star(10) + expect_false(is_directed(g)) + + # Can still create directed stars + g_in <- make_star(10, mode = "in") + expect_true(is_directed(g_in)) + + g_out <- make_star(10, mode = "out") + expect_true(is_directed(g_out)) +}) + +test_that("make_graph() defaults to undirected", { + g <- make_graph(c(1, 2, 2, 3, 3, 4)) + expect_false(is_directed(g)) + + # Can still create directed graphs + g_dir <- make_graph(c(1, 2, 2, 3, 3, 4), directed = TRUE) + expect_true(is_directed(g_dir)) +}) + # ---- ellipsis migration: argument coverage ---------------------------- test_that("make_empty_graph() tail arguments and positional recovery", { diff --git a/tests/testthat/test-paths.R b/tests/testthat/test-paths.R index 282643899db..fa8ff5d3dcc 100644 --- a/tests/testthat/test-paths.R +++ b/tests/testthat/test-paths.R @@ -1,6 +1,6 @@ test_that("radius() works", { igraph_local_seed(42) - g <- make_tree(10, 2) + g <- make_tree(10, 2, mode = "out") expect_equal(radius(g), 3) expect_equal(radius(g, mode = "in"), 0) @@ -18,14 +18,14 @@ test_that("radius() works -- weights", { test_that("radius() works -- lifecycle", { rlang::local_options(lifecycle_verbosity = "warning") igraph_local_seed(42) - g <- make_tree(10, 2) + g <- make_tree(10, 2, mode = "out") expect_snapshot(radius(g, "out")) }) test_that("eccentricity() works", { igraph_local_seed(42) - g <- make_tree(10, 2) + g <- make_tree(10, 2, mode = "out") expect_equal(eccentricity(g), c(3, 3, 4, 4, 4, 5, 5, 5, 5, 5)) expect_equal(eccentricity(g, mode = "in"), c(0, 1, 1, 2, 2, 2, 2, 3, 3, 3)) @@ -43,14 +43,14 @@ test_that("eccentricity() works -- weights", { test_that("eccentricity() works -- lifecycle", { rlang::local_options(lifecycle_verbosity = "warning") igraph_local_seed(42) - g <- make_tree(10, 2) + g <- make_tree(10, 2, mode = "out") expect_snapshot(eccentricity(g, vids = V(g), "out")) }) test_that("graph_center() works", { igraph_local_seed(42) - g <- make_tree(100, 7) + g <- make_tree(100, 7, mode = "out") expect_equal(as.numeric(graph_center(g)), c(1, 2)) expect_equal(as.numeric(graph_center(g, mode = "in")), 1) expect_equal(as.numeric(graph_center(g, mode = "out")), 16:100) diff --git a/tests/testthat/test-print-classic.R b/tests/testthat/test-print-classic.R index b488622800c..f96b142a8b0 100644 --- a/tests/testthat/test-print-classic.R +++ b/tests/testthat/test-print-classic.R @@ -32,7 +32,7 @@ test_that("classic: print.igraph() works", { expect_output(print(g3), "1 --") igraph_with_seed(42, { - g4 <- make_star(100) + g4 <- make_star(100, mode = "in") }) expect_output(print(g4), "2->1") diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index b7768c9e907..8e96c80eb69 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -4,7 +4,7 @@ test_that("dfs() uses 1-based root vertex index", { }) test_that("dfs() does not pad order", { - g <- make_star(3) + g <- make_star(3, mode = "in") expect_equal(as.numeric(dfs(g, root = 2, unreachable = FALSE)$order), c(2, 1)) local_igraph_options(return.vs.es = FALSE) @@ -18,7 +18,7 @@ test_that("dfs() does not pad order", { }) test_that("dfs() deprecated arguments", { - g <- make_star(3) + g <- make_star(3, mode = "in") expect_snapshot_igraph_error({ d <- dfs( @@ -261,7 +261,7 @@ test_that("bfs() deprecated arguments", { }) test_that("bfs() does not pad order", { - g <- make_star(3) + g <- make_star(3, mode = "in") expect_equal(as.numeric(bfs(g, root = 2, unreachable = FALSE)$order), c(2, 1)) local_igraph_options(return.vs.es = FALSE) @@ -462,7 +462,7 @@ test_that("shortest_paths() works", { }) test_that("shortest_paths() can handle negative weights", { - g <- make_tree(7) + g <- make_tree(7, mode = "out") E(g)$weight <- -1 sps <- shortest_paths(g, 2)$vpath @@ -745,14 +745,14 @@ test_that("max_bipartite_match() handles missing types gracefully", { }) test_that("unfold_tree() works", { - g <- make_tree(7, 2) + g <- make_tree(7, 2, mode = "out") g <- add_edges(g, c(2, 7, 1, 4)) g2 <- unfold_tree(g, roots = 1) expect_isomorphic( g2$tree, make_graph(c( 1, 2, 1, 3, 2, 8, 2, 5, 3, 6, 3, 9, 2, 7, 1, 4 - )) + ), directed = TRUE) ) expect_equal(g2$vertex_index, c(1, 2, 3, 4, 5, 6, 7, 4, 7)) }) @@ -956,8 +956,11 @@ test_that("any_multiple(), count_multiple(), which_multiple() works", { ) ## Direction of the edge is important - expect_false(any_multiple(make_graph(c(1, 2, 2, 1)))) - expect_equal(which_multiple(make_graph(c(1, 2, 2, 1))), c(FALSE, FALSE)) + expect_false(any_multiple(make_graph(c(1, 2, 2, 1), directed = TRUE))) + expect_equal( + which_multiple(make_graph(c(1, 2, 2, 1), directed = TRUE)), + c(FALSE, FALSE) + ) expect_equal( which_multiple(make_graph(c(1, 2, 2, 1), dir = FALSE)), c(FALSE, TRUE) diff --git a/tests/vdiffr.Rout.fail b/tests/vdiffr.Rout.fail new file mode 100644 index 00000000000..3570f96afac --- /dev/null +++ b/tests/vdiffr.Rout.fail @@ -0,0 +1,446 @@ +Environment: +- vdiffr-svg-engine: 2.0 +- vdiffr: 1.0.8 + + +Failed doppelganger: mixed-vertex-parameters (/home/runner/work/rigraph/rigraph/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg) + +< before +> after +@@ 26,14 / 26,9 @@ + + +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> + + + + +Failed doppelganger: mixed-vertex-parameters (/home/runner/work/rigraph/rigraph/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg) + +< before +> after +@@ 26,14 / 26,9 @@ + + +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> + + + + +Failed doppelganger: mixed-vertex-parameters (/home/runner/work/rigraph/rigraph/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg) + +< before +> after +@@ 26,14 / 26,9 @@ + + +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> + + + + +Failed doppelganger: mixed-vertex-parameters (/home/runner/work/rigraph/rigraph/tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg) + +< before +> after +@@ 26,14 / 26,9 @@ + + +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> + + + + +Failed doppelganger: rectangle-edges (/home/runner/work/rigraph/rigraph/tests/testthat/_snaps/plot/rectangle-edges.svg) + +< before +> after +@@ 26,20 / 26,12 @@ + + +< +> +< +> +< +< +< +> +> +> +< +> +< +< +< +< +< +< +< +< +< +< +> +> + + + + +Failed doppelganger: rectangle-edges (/home/runner/work/rigraph/rigraph/tests/testthat/_snaps/plot/rectangle-edges.svg) + +< before +> after +@@ 26,20 / 26,12 @@ + + +< +> +< +> +< +< +< +> +> +> +< +> +< +< +< +< +< +< +< +< +< +< +> +> + + + diff --git a/tools/migrations/make.R b/tools/migrations/make.R index 013daccbc2d..5f107b3550d 100644 --- a/tools/migrations/make.R +++ b/tools/migrations/make.R @@ -194,7 +194,7 @@ migrations <- list( new = function( n, ..., - mode = c("in", "out", "mutual", "undirected"), + mode = c("undirected", "in", "out", "mutual"), center = 1 ) {}, when = "3.0.0" @@ -206,7 +206,7 @@ migrations <- list( n, children = 2, ..., - mode = c("out", "in", "undirected") + mode = c("undirected", "out", "in") ) {}, when = "3.0.0" ),