Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions R/make.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ graph <- function(
...,
n = max(edges),
isolates = NULL,
directed = TRUE,
directed = FALSE,
dir = directed,
simplify = TRUE
) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1429,7 +1425,7 @@ make_graph <- function(
...,
n = max(edges),
isolates = NULL,
directed = TRUE,
directed = FALSE,
dir = directed,
simplify = TRUE
) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand All @@ -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"),
Expand Down Expand Up @@ -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) {
Expand All @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion man/graph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/graph.star.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/graph.tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/make_graph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/make_star.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/make_tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/_snaps/aaa-auto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
36 changes: 18 additions & 18 deletions tests/testthat/_snaps/conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

---

Expand All @@ -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,] . . .

---
Expand All @@ -382,7 +382,7 @@

[1,] . . .
[2,] 2.1 . .
[3,] 3.2 4.3 .
[3,] 4.3 3.2 .

---

Expand All @@ -391,28 +391,28 @@
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 .

---

Code
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

---

Code
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

---
Expand All @@ -423,17 +423,17 @@
[,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

---

Code
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

---

Expand Down
15 changes: 5 additions & 10 deletions tests/testthat/_snaps/plot.shapes/mixed-vertex-parameters.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 8 additions & 16 deletions tests/testthat/_snaps/plot/rectangle-edges.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/testthat/helper-indexing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-aaa-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down
Loading