From 0523d436cedb10084038946842fc75b0846bfd6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= <maelle.salmon@yahoo.se>
Date: Thu, 28 Nov 2024 10:11:48 +0100
Subject: [PATCH 1/5] refactor: adapt to cut.prob's new handling of NULL in the
 C core

Simpler default for the R interface
---
 R/motifs.R                   | 43 ++++++++++++++++++++++--------------
 man/count_motifs.Rd          |  5 +++--
 man/graph.motifs.Rd          |  5 +++--
 man/graph.motifs.est.Rd      |  5 +++--
 man/graph.motifs.no.Rd       |  5 +++--
 man/sample_motifs.Rd         |  3 ++-
 tests/testthat/test-motifs.R | 16 +++++++-------
 7 files changed, 48 insertions(+), 34 deletions(-)

diff --git a/R/motifs.R b/R/motifs.R
index 5414a06712..4968d79d3b 100644
--- a/R/motifs.R
+++ b/R/motifs.R
@@ -24,7 +24,7 @@ triad.census <- function(graph) { # nocov start
 #' @inheritParams count_motifs
 #' @keywords internal
 #' @export
-graph.motifs.no <- function(graph, size = 3, cut.prob = rep(0, size)) { # nocov start
+graph.motifs.no <- function(graph, size = 3, cut.prob = NULL) { # nocov start
   lifecycle::deprecate_soft("2.0.0", "graph.motifs.no()", "count_motifs()")
   count_motifs(graph = graph, size = size, cut.prob = cut.prob)
 } # nocov end
@@ -39,7 +39,7 @@ graph.motifs.no <- function(graph, size = 3, cut.prob = rep(0, size)) { # nocov
 #' @inheritParams sample_motifs
 #' @keywords internal
 #' @export
-graph.motifs.est <- function(graph, size = 3, cut.prob = rep(0, size), sample.size = vcount(graph) / 10, sample = NULL) { # nocov start
+graph.motifs.est <- function(graph, size = 3, cut.prob = NULL, sample.size = vcount(graph) / 10, sample = NULL) { # nocov start
   lifecycle::deprecate_soft("2.0.0", "graph.motifs.est()", "sample_motifs()")
   sample_motifs(graph = graph, size = size, cut.prob = cut.prob, sample.size = sample.size, sample = sample)
 } # nocov end
@@ -54,7 +54,7 @@ graph.motifs.est <- function(graph, size = 3, cut.prob = rep(0, size), sample.si
 #' @inheritParams motifs
 #' @keywords internal
 #' @export
-graph.motifs <- function(graph, size = 3, cut.prob = rep(0, size)) { # nocov start
+graph.motifs <- function(graph, size = 3, cut.prob = NULL) { # nocov start
   lifecycle::deprecate_soft("2.0.0", "graph.motifs()", "motifs()")
   motifs(graph = graph, size = size, cut.prob = cut.prob)
 } # nocov end
@@ -110,7 +110,8 @@ dyad.census <- function(graph) { # nocov start
 #'   directed graphs and sizes 3-6 in undirected graphs.
 #' @param cut.prob Numeric vector giving the probabilities that the search
 #'   graph is cut at a certain level. Its length should be the same as the size
-#'   of the motif (the `size` argument). By default no cuts are made.
+#'   of the motif (the `size` argument).
+#'   If `NULL`, the default, no cuts are made.
 #' @return `motifs()` returns a numeric vector, the number of occurrences of
 #'   each motif in the graph. The motifs are ordered by their isomorphism
 #'   classes. Note that for unconnected subgraphs, which are not considered to be
@@ -125,10 +126,12 @@ dyad.census <- function(graph) { # nocov start
 #' motifs(g, 3)
 #' count_motifs(g, 3)
 #' sample_motifs(g, 3)
-motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
+motifs <- function(graph, size = 3, cut.prob = NULL) {
   ensure_igraph(graph)
-  cut.prob <- as.numeric(cut.prob)
-  if (length(cut.prob) != size) {
+
+  if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob)
+
+  if (!is.null(cut.prob) && length(cut.prob) != size) {
     cut.prob <- c(
       cut.prob[-length(cut.prob)],
       rep(cut.prob[-length(cut.prob)], length(cut.prob) - 1)
@@ -138,7 +141,7 @@ motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
   on.exit(.Call(R_igraph_finalizer))
   res <- .Call(
     R_igraph_motifs_randesu, graph, as.numeric(size),
-    as.numeric(cut.prob)
+    cut.prob
   )
   res[is.nan(res)] <- NA
   res
@@ -156,7 +159,8 @@ motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
 #' @param size The size of the motif.
 #' @param cut.prob Numeric vector giving the probabilities that the search
 #'   graph is cut at a certain level. Its length should be the same as the size
-#'   of the motif (the `size` argument). By default no cuts are made.
+#'   of the motif (the `size` argument).
+#'   If `NULL`, the default, no cuts are made.
 #' @return `count_motifs()` returns  a numeric scalar.
 #' @seealso [isomorphism_class()]
 #'
@@ -168,10 +172,12 @@ motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
 #' motifs(g, 3)
 #' count_motifs(g, 3)
 #' sample_motifs(g, 3)
-count_motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
+count_motifs <- function(graph, size = 3, cut.prob = NULL) {
   ensure_igraph(graph)
-  cut.prob <- as.numeric(cut.prob)
-  if (length(cut.prob) != size) {
+
+  if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob)
+
+  if (!is.null(cut.prob) && length(cut.prob) != size) {
     cut.prob <- c(
       cut.prob[-length(cut.prob)],
       rep(cut.prob[-length(cut.prob)], length(cut.prob) - 1)
@@ -181,7 +187,7 @@ count_motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
   on.exit(.Call(R_igraph_finalizer))
   .Call(
     R_igraph_motifs_randesu_no, graph, as.numeric(size),
-    as.numeric(cut.prob)
+    cut.prob
   )
 }
 
@@ -198,7 +204,8 @@ count_motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
 #'   in directed graphs and sizes 3-6 in undirected graphs.
 #' @param cut.prob Numeric vector giving the probabilities that the search
 #'   graph is cut at a certain level. Its length should be the same as the size
-#'   of the motif (the `size` argument). By default no cuts are made.
+#'   of the motif (the `size` argument).
+#'   If `NULL`, the default, no cuts are made.
 #' @param sample.size The number of vertices to use as a starting point for
 #'   finding motifs. Only used if the `sample` argument is `NULL`.
 #'   The default is `ceiling(vcount(graph) / 10)` .
@@ -224,8 +231,10 @@ sample_motifs <- function(
   sample = NULL
 ) {
   ensure_igraph(graph)
-  cut.prob <- as.numeric(cut.prob)
-  if (length(cut.prob) != size) {
+
+  if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob)
+
+  if (!is.null(cut.prob) && length(cut.prob) != size) {
     cut.prob <- c(
       cut.prob[-length(cut.prob)],
       rep(cut.prob[-length(cut.prob)], length(cut.prob) - 1)
@@ -244,7 +253,7 @@ sample_motifs <- function(
   on.exit(.Call(R_igraph_finalizer))
   .Call(
     R_igraph_motifs_randesu_estimate, graph, as.numeric(size),
-    as.numeric(cut.prob), as.numeric(sample.size), sample
+    cut.prob, as.numeric(sample.size), sample
   )
 }
 
diff --git a/man/count_motifs.Rd b/man/count_motifs.Rd
index 3952cb1ccb..8d25e6d3c4 100644
--- a/man/count_motifs.Rd
+++ b/man/count_motifs.Rd
@@ -4,7 +4,7 @@
 \alias{count_motifs}
 \title{Graph motifs}
 \usage{
-count_motifs(graph, size = 3, cut.prob = rep(0, size))
+count_motifs(graph, size = 3, cut.prob = NULL)
 }
 \arguments{
 \item{graph}{Graph object, the input graph.}
@@ -13,7 +13,8 @@ count_motifs(graph, size = 3, cut.prob = rep(0, size))
 
 \item{cut.prob}{Numeric vector giving the probabilities that the search
 graph is cut at a certain level. Its length should be the same as the size
-of the motif (the \code{size} argument). By default no cuts are made.}
+of the motif (the \code{size} argument).
+If \code{NULL}, the default, no cuts are made.}
 }
 \value{
 \code{count_motifs()} returns  a numeric scalar.
diff --git a/man/graph.motifs.Rd b/man/graph.motifs.Rd
index 00ff37371b..e1481b26a0 100644
--- a/man/graph.motifs.Rd
+++ b/man/graph.motifs.Rd
@@ -4,7 +4,7 @@
 \alias{graph.motifs}
 \title{Graph motifs}
 \usage{
-graph.motifs(graph, size = 3, cut.prob = rep(0, size))
+graph.motifs(graph, size = 3, cut.prob = NULL)
 }
 \arguments{
 \item{graph}{Graph object, the input graph.}
@@ -14,7 +14,8 @@ directed graphs and sizes 3-6 in undirected graphs.}
 
 \item{cut.prob}{Numeric vector giving the probabilities that the search
 graph is cut at a certain level. Its length should be the same as the size
-of the motif (the \code{size} argument). By default no cuts are made.}
+of the motif (the \code{size} argument).
+If \code{NULL}, the default, no cuts are made.}
 }
 \description{
 \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
diff --git a/man/graph.motifs.est.Rd b/man/graph.motifs.est.Rd
index 0fdc61c397..cbd1fdbcad 100644
--- a/man/graph.motifs.est.Rd
+++ b/man/graph.motifs.est.Rd
@@ -7,7 +7,7 @@
 graph.motifs.est(
   graph,
   size = 3,
-  cut.prob = rep(0, size),
+  cut.prob = NULL,
   sample.size = vcount(graph)/10,
   sample = NULL
 )
@@ -20,7 +20,8 @@ in directed graphs and sizes 3-6 in undirected graphs.}
 
 \item{cut.prob}{Numeric vector giving the probabilities that the search
 graph is cut at a certain level. Its length should be the same as the size
-of the motif (the \code{size} argument). By default no cuts are made.}
+of the motif (the \code{size} argument).
+If \code{NULL}, the default, no cuts are made.}
 
 \item{sample.size}{The number of vertices to use as a starting point for
 finding motifs. Only used if the \code{sample} argument is \code{NULL}.
diff --git a/man/graph.motifs.no.Rd b/man/graph.motifs.no.Rd
index 238fedc1b4..bf016df237 100644
--- a/man/graph.motifs.no.Rd
+++ b/man/graph.motifs.no.Rd
@@ -4,7 +4,7 @@
 \alias{graph.motifs.no}
 \title{Graph motifs}
 \usage{
-graph.motifs.no(graph, size = 3, cut.prob = rep(0, size))
+graph.motifs.no(graph, size = 3, cut.prob = NULL)
 }
 \arguments{
 \item{graph}{Graph object, the input graph.}
@@ -13,7 +13,8 @@ graph.motifs.no(graph, size = 3, cut.prob = rep(0, size))
 
 \item{cut.prob}{Numeric vector giving the probabilities that the search
 graph is cut at a certain level. Its length should be the same as the size
-of the motif (the \code{size} argument). By default no cuts are made.}
+of the motif (the \code{size} argument).
+If \code{NULL}, the default, no cuts are made.}
 }
 \description{
 \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
diff --git a/man/sample_motifs.Rd b/man/sample_motifs.Rd
index a7b50afbd0..26207a803c 100644
--- a/man/sample_motifs.Rd
+++ b/man/sample_motifs.Rd
@@ -20,7 +20,8 @@ in directed graphs and sizes 3-6 in undirected graphs.}
 
 \item{cut.prob}{Numeric vector giving the probabilities that the search
 graph is cut at a certain level. Its length should be the same as the size
-of the motif (the \code{size} argument). By default no cuts are made.}
+of the motif (the \code{size} argument).
+If \code{NULL}, the default, no cuts are made.}
 
 \item{sample.size}{The number of vertices to use as a starting point for
 finding motifs. Only used if the \code{sample} argument is \code{NULL}.
diff --git a/tests/testthat/test-motifs.R b/tests/testthat/test-motifs.R
index 3d85c2c95b..5b5430389e 100644
--- a/tests/testthat/test-motifs.R
+++ b/tests/testthat/test-motifs.R
@@ -10,7 +10,7 @@ test_that("motif finding works", {
   mno2 <- count_motifs(b, cut.prob = c(0, 1 / 3, 0))
   expect_equal(
     c(mno0 / mno, mno1 / mno, mno2 / mno),
-    c(0.654821903845065, 0.666289144345659, 0.668393831285275)
+    c(0.674541153079009, 0.666138135417257, 0.665968250372803)
   )
 
   mno3 <- count_motifs(b, cut.prob = c(0, 1 / 3, 1 / 3))
@@ -18,7 +18,7 @@ test_that("motif finding works", {
   mno5 <- count_motifs(b, cut.prob = c(1 / 3, 1 / 3, 0))
   expect_equal(
     c(mno3 / mno, mno4 / mno, mno5 / mno),
-    c(0.443959957465819, 0.441952797125797, 0.446004870037941)
+    c(0.441707407617142, 0.445633639755617, 0.440527650363994)
   )
 
   ######################
@@ -31,18 +31,18 @@ test_that("motif finding works", {
   m0 <- motifs(b, cut.prob = c(1 / 3, 0, 0))
   m1 <- motifs(b, cut.prob = c(0, 1 / 3, 0))
   m2 <- motifs(b, cut.prob = c(0, 0, 1 / 3))
-  expect_equal(m0 / m, c(NA, NA, 0.653972107372707, NA, 0.653993015279859, 0.612244897959184, 0.657514670174019, 0.63013698630137, NaN, 0.538461538461538, NaN, 0.565217391304348, NaN, NaN, NaN, NaN))
-  expect_equal(m1 / m, c(NA, NA, 0.669562138856225, NA, 0.66808158454082, 0.73469387755102, 0.670819000404694, 0.657534246575342, NaN, 0.769230769230769, NaN, 0.739130434782609, NaN, NaN, NaN, NaN))
-  expect_equal(m2 / m, c(NA, NA, 0.666451718949538, NA, 0.665291458452201, 0.591836734693878, 0.666683528935654, 0.671232876712329, NaN, 0.753846153846154, NaN, 0.565217391304348, NaN, NaN, NaN, NaN))
+  expect_equal(m0 / m, c(NA, NA, 0.672381747145621, NA, 0.674984795380304, 0.63265306122449, 0.675738567381627, 0.698630136986301, NaN, 0.784615384615385, NaN, 0.608695652173913, NaN, NaN, NaN, NaN))
+  expect_equal(m1 / m, c(NA, NA, 0.66650229488298, NA, 0.666263300123518, 0.63265306122449, 0.66845406717928, 0.671232876712329, NaN, 0.6, NaN, 0.695652173913043, NaN, NaN, NaN, NaN))
+  expect_equal(m2 / m, c(NA, NA, 0.663265435142687, NA, 0.667442050021631, 0.653061224489796, 0.666278834479968, 0.657534246575342, NaN, 0.661538461538462, NaN, 0.652173913043478, NaN, NaN, NaN, NaN))
 
   m3 <- motifs(b, cut.prob = c(0, 1 / 3, 1 / 3))
   m4 <- motifs(b, cut.prob = c(1 / 3, 1 / 3, 0))
   m5 <- motifs(b, cut.prob = c(1 / 3, 1 / 3, 0))
-  expect_equal(m3 / m, c(NA, NA, 0.445611905574732, NA, 0.442789875290769, 0.448979591836735, 0.444695973290166, 0.424657534246575, NaN, 0.369230769230769, NaN, 0.608695652173913, NaN, NaN, NaN, NaN))
+  expect_equal(m3 / m, c(NA, NA, 0.439062322193984, NA, 0.441742794264253, 0.408163265306122, 0.44431657223796, 0.438356164383562, NaN, 0.415384615384615, NaN, 0.478260869565217, NaN, NaN, NaN, NaN))
 
-  expect_equal(m4 / m, c(NA, NA, 0.439251981944392, NA, 0.439284975327761, 0.73469387755102, 0.445088021044112, 0.465753424657534, NaN, 0.630769230769231, NaN, 0.565217391304348, NaN, NaN, NaN, NaN))
+  expect_equal(m4 / m, c(NA, NA, 0.439770385262173, NA, 0.441040560282398, 0.224489795918367, 0.438752023472278, 0.534246575342466, NaN, 0.430769230769231, NaN, 0.391304347826087, NaN, NaN, NaN, NaN))
 
-  expect_equal(m5 / m, c(NA, NA, 0.439985332979302, NA, 0.440288166730411, 0.346938775510204, 0.44159753136382, 0.452054794520548, NaN, 0.323076923076923, NaN, 0.347826086956522, NaN, NaN, NaN, NaN))
+  expect_equal(m5 / m, c(NA, NA, 0.444436015122204, NA, 0.445736750036052, 0.489795918367347, 0.445353601780656, 0.575342465753425, NaN, 0.415384615384615, NaN, 0.347826086956522, NaN, NaN, NaN, NaN))
 })
 
 test_that("sample_motifs works", {

From 5fd11376253c919661067f954e4735cfdd8f886c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= <maelle.salmon@yahoo.se>
Date: Wed, 19 Feb 2025 12:52:52 +0100
Subject: [PATCH 2/5] document()

---
 .Rbuildignore                      |  6 +++---
 man/dominator_tree.Rd              |  6 +++---
 man/edge_connectivity.Rd           |  2 +-
 man/graph_from_adjacency_matrix.Rd | 14 +++++++-------
 man/motifs.Rd                      |  5 +++--
 man/sample_chung_lu.Rd             |  2 +-
 man/st_cuts.Rd                     |  6 +++---
 man/st_min_cuts.Rd                 |  4 ++--
 8 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/.Rbuildignore b/.Rbuildignore
index cb62bebd9f..ad8aef71c5 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -52,11 +52,11 @@
 ^compile_commands\.json$
 ^\.cache$
 ^rchk$
+^vendor\.sh$
+^vendor-one\.sh$
+^patch$
 ^man/dot-igraph.progress\.Rd$
 ^man/dot-igraph.status\.Rd$
 ^man/dot-extract_constructor_and_modifiers\.Rd$
 ^man/dot-apply_modifiers\.Rd$
 ^man/handle_vertex_type_arg\.Rd$
-^vendor\.sh$
-^vendor-one\.sh$
-^patch$
diff --git a/man/dominator_tree.Rd b/man/dominator_tree.Rd
index 230b9b9a40..5fa5bd1a00 100644
--- a/man/dominator_tree.Rd
+++ b/man/dominator_tree.Rd
@@ -50,9 +50,9 @@ dominator tree of a directed graph. For details see the reference below.
 
 ## The example from the paper
 g <- graph_from_literal(
-  R -+ A:B:C, A -+ D, B -+ A:D:E, C -+ F:G, D -+ L,
-  E -+ H, F -+ I, G -+ I:J, H -+ E:K, I -+ K, J -+ I,
-  K -+ I:R, L -+ H
+  R - +A:B:C, A - +D, B - +A:D:E, C - +F:G, D - +L,
+  E - +H, F - +I, G - +I:J, H - +E:K, I - +K, J - +I,
+  K - +I:R, L - +H
 )
 dtree <- dominator_tree(g, root = "R")
 layout <- layout_as_tree(dtree$domtree, root = "R")
diff --git a/man/edge_connectivity.Rd b/man/edge_connectivity.Rd
index e2b96878aa..914232a4be 100644
--- a/man/edge_connectivity.Rd
+++ b/man/edge_connectivity.Rd
@@ -8,7 +8,7 @@
 \usage{
 edge_connectivity(graph, source = NULL, target = NULL, checks = TRUE)
 
-edge_disjoint_paths(graph, source, target)
+edge_disjoint_paths(graph, source = NULL, target = NULL)
 
 adhesion(graph, checks = TRUE)
 }
diff --git a/man/graph_from_adjacency_matrix.Rd b/man/graph_from_adjacency_matrix.Rd
index 7bc37508c2..bb04f03a7c 100644
--- a/man/graph_from_adjacency_matrix.Rd
+++ b/man/graph_from_adjacency_matrix.Rd
@@ -104,15 +104,15 @@ weights.} }
 \examples{
 
 g1 <- sample(
-    x = 0:1, size = 100, replace = TRUE,
-    prob = c(0.9, 0.1)
-  ) \%>\%
+  x = 0:1, size = 100, replace = TRUE,
+  prob = c(0.9, 0.1)
+) \%>\%
   matrix(ncol = 10) \%>\%
   graph_from_adjacency_matrix()
 
 g2 <- sample(
-    x = 0:5, size = 100, replace = TRUE,
-    prob = c(0.9, 0.02, 0.02, 0.02, 0.02, 0.02)
+  x = 0:5, size = 100, replace = TRUE,
+  prob = c(0.9, 0.02, 0.02, 0.02, 0.02, 0.02)
 ) \%>\%
   matrix(ncol = 10) \%>\%
   graph_from_adjacency_matrix(weighted = TRUE)
@@ -178,8 +178,8 @@ halve_diag <- function(x) {
   x
 }
 expected_g8_weights <- non_zero_sort(
-  halve_diag(adj_matrix + t(adj_matrix)
-)[lower.tri(adj_matrix, diag = TRUE)])
+  halve_diag(adj_matrix + t(adj_matrix))[lower.tri(adj_matrix, diag = TRUE)]
+)
 actual_g8_weights <- sort(E(g8)$weight)
 all(expected_g8_weights == actual_g8_weights)
 
diff --git a/man/motifs.Rd b/man/motifs.Rd
index 0ad6157b7e..9d6de29627 100644
--- a/man/motifs.Rd
+++ b/man/motifs.Rd
@@ -4,7 +4,7 @@
 \alias{motifs}
 \title{Graph motifs}
 \usage{
-motifs(graph, size = 3, cut.prob = rep(0, size))
+motifs(graph, size = 3, cut.prob = NULL)
 }
 \arguments{
 \item{graph}{Graph object, the input graph.}
@@ -14,7 +14,8 @@ directed graphs and sizes 3-6 in undirected graphs.}
 
 \item{cut.prob}{Numeric vector giving the probabilities that the search
 graph is cut at a certain level. Its length should be the same as the size
-of the motif (the \code{size} argument). By default no cuts are made.}
+of the motif (the \code{size} argument).
+If \code{NULL}, the default, no cuts are made.}
 }
 \value{
 \code{motifs()} returns a numeric vector, the number of occurrences of
diff --git a/man/sample_chung_lu.Rd b/man/sample_chung_lu.Rd
index 529bd7fa22..d69ed3b4d4 100644
--- a/man/sample_chung_lu.Rd
+++ b/man/sample_chung_lu.Rd
@@ -131,7 +131,7 @@ rowMeans(replicate(
 
 rowMeans(replicate(
   100,
-  degree(sample_chung_lu(c(1, 3, 2, 1), c(2, 1, 2, 2), variant = "maxent"), mode='out')
+  degree(sample_chung_lu(c(1, 3, 2, 1), c(2, 1, 2, 2), variant = "maxent"), mode = "out")
 ))
 }
 \references{
diff --git a/man/st_cuts.Rd b/man/st_cuts.Rd
index d8922a74bc..d734c2bc2f 100644
--- a/man/st_cuts.Rd
+++ b/man/st_cuts.Rd
@@ -34,13 +34,13 @@ removing these edges from \eqn{G} there is no directed path from \eqn{s} to
 \examples{
 
 # A very simple graph
-g <- graph_from_literal(a -+ b -+ c -+ d -+ e)
+g <- graph_from_literal(a - +b - +c - +d - +e)
 st_cuts(g, source = "a", target = "e")
 
 # A somewhat more difficult graph
 g2 <- graph_from_literal(
-  s --+ a:b, a:b --+ t,
-  a --+ 1:2:3, 1:2:3 --+ b
+  s - -+a:b, a:b - -+t,
+  a - -+1:2:3, 1:2:3 - -+b
 )
 st_cuts(g2, source = "s", target = "t")
 }
diff --git a/man/st_min_cuts.Rd b/man/st_min_cuts.Rd
index 111c13a604..e63aace2b5 100644
--- a/man/st_min_cuts.Rd
+++ b/man/st_min_cuts.Rd
@@ -49,8 +49,8 @@ An \eqn{(s,t)}-cut is minimum if it is of the smallest possible size.
 
 # A difficult graph, from the Provan-Shier paper
 g <- graph_from_literal(
-  s --+ a:b, a:b --+ t,
-  a --+ 1:2:3:4:5, 1:2:3:4:5 --+ b
+  s - -+a:b, a:b - -+t,
+  a - -+1:2:3:4:5, 1:2:3:4:5 - -+b
 )
 st_min_cuts(g, source = "s", target = "t")
 }

From a09f8c27e3c4b77a49dbb18e1df3c3903cd56222 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= <maelle.salmon@yahoo.se>
Date: Thu, 6 Mar 2025 09:54:45 +0100
Subject: [PATCH 3/5] don't change deprecated functions

---
 R/motifs.R                  |  3 +-
 man/dominator_tree.Rd       |  6 +--
 man/graph.motifs.no.Rd      |  2 +-
 man/igraph-vs-indexing.Rd   |  4 +-
 man/layout.drl.Rd           |  2 +-
 man/layout_with_dh.Rd       |  2 +-
 man/layout_with_drl.Rd      |  2 +-
 man/layout_with_sugiyama.Rd | 82 ++++++++++++++++++-------------------
 man/reverse_edges.Rd        |  2 +-
 man/st_cuts.Rd              |  6 +--
 man/st_min_cuts.Rd          |  4 +-
 man/vertex.shape.pie.Rd     | 10 +++--
 12 files changed, 64 insertions(+), 61 deletions(-)

diff --git a/R/motifs.R b/R/motifs.R
index dfe0cf49b9..5dbeb61ae5 100644
--- a/R/motifs.R
+++ b/R/motifs.R
@@ -23,7 +23,8 @@ triad.census <- function(graph) { # nocov start
 #' @inheritParams count_motifs
 #' @keywords internal
 #' @export
-graph.motifs.no <- function(graph, size = 3, cut.prob = NULL) { # nocov start
+graph.motifs.no <- function(graph, size = 3, cut.prob = rep(0, size)) {
+  # nocov start
   lifecycle::deprecate_soft("2.0.0", "graph.motifs.no()", "count_motifs()")
   count_motifs(graph = graph, size = size, cut.prob = cut.prob)
 } # nocov end
diff --git a/man/dominator_tree.Rd b/man/dominator_tree.Rd
index 5fa5bd1a00..230b9b9a40 100644
--- a/man/dominator_tree.Rd
+++ b/man/dominator_tree.Rd
@@ -50,9 +50,9 @@ dominator tree of a directed graph. For details see the reference below.
 
 ## The example from the paper
 g <- graph_from_literal(
-  R - +A:B:C, A - +D, B - +A:D:E, C - +F:G, D - +L,
-  E - +H, F - +I, G - +I:J, H - +E:K, I - +K, J - +I,
-  K - +I:R, L - +H
+  R -+ A:B:C, A -+ D, B -+ A:D:E, C -+ F:G, D -+ L,
+  E -+ H, F -+ I, G -+ I:J, H -+ E:K, I -+ K, J -+ I,
+  K -+ I:R, L -+ H
 )
 dtree <- dominator_tree(g, root = "R")
 layout <- layout_as_tree(dtree$domtree, root = "R")
diff --git a/man/graph.motifs.no.Rd b/man/graph.motifs.no.Rd
index bf016df237..15e01bcec7 100644
--- a/man/graph.motifs.no.Rd
+++ b/man/graph.motifs.no.Rd
@@ -4,7 +4,7 @@
 \alias{graph.motifs.no}
 \title{Graph motifs}
 \usage{
-graph.motifs.no(graph, size = 3, cut.prob = NULL)
+graph.motifs.no(graph, size = 3, cut.prob = rep(0, size))
 }
 \arguments{
 \item{graph}{Graph object, the input graph.}
diff --git a/man/igraph-vs-indexing.Rd b/man/igraph-vs-indexing.Rd
index d1969139ba..3cf94e62be 100644
--- a/man/igraph-vs-indexing.Rd
+++ b/man/igraph-vs-indexing.Rd
@@ -122,14 +122,14 @@ V(g)[.nei(c(2, 4), "out")]
 
 # -----------------------------------------------------------------
 # The same with vertex names
-g <- make_graph(~ A -+ B, B -+ C:D, D -+ B)
+g <- make_graph(~ A - +B, B - +C:D, D - +B)
 V(g)[.nei(c("B", "D"))]
 V(g)[.nei(c("B", "D"), "in")]
 V(g)[.nei(c("B", "D"), "out")]
 
 # -----------------------------------------------------------------
 # Resolving attributes
-g <- make_graph(~ A -+ B, B -+ C:D, D -+ B)
+g <- make_graph(~ A - +B, B - +C:D, D - +B)
 V(g)$color <- c("red", "red", "green", "green")
 V(g)[color == "red"]
 
diff --git a/man/layout.drl.Rd b/man/layout.drl.Rd
index 6ebc75bcff..0457d084ea 100644
--- a/man/layout.drl.Rd
+++ b/man/layout.drl.Rd
@@ -1,5 +1,5 @@
 % Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/layout_drl.R
+% Please edit documentation in R/layout.R
 \name{layout.drl}
 \alias{layout.drl}
 \title{The DrL graph layout generator}
diff --git a/man/layout_with_dh.Rd b/man/layout_with_dh.Rd
index f43bc2f364..4defd24637 100644
--- a/man/layout_with_dh.Rd
+++ b/man/layout_with_dh.Rd
@@ -102,7 +102,7 @@ plot(g_5b, layout = layout_with_dh, vertex.size = 5, vertex.label = NA)
 g_6 <- make_lattice(c(2, 2, 2))
 plot(g_6, layout = layout_with_dh)
 
-g_7 <- graph_from_literal(1:3:5 -- 2:4:6)
+g_7 <- graph_from_literal(1:3:5 - -2:4:6)
 plot(g_7, layout = layout_with_dh, vertex.label = V(g_7)$name)
 
 g_8 <- make_ring(5) + make_ring(10) + make_ring(5) +
diff --git a/man/layout_with_drl.Rd b/man/layout_with_drl.Rd
index e77f6f62c9..f9d4dd00c9 100644
--- a/man/layout_with_drl.Rd
+++ b/man/layout_with_drl.Rd
@@ -1,5 +1,5 @@
 % Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/layout_drl.R
+% Please edit documentation in R/layout.R
 \name{layout_with_drl}
 \alias{layout_with_drl}
 \alias{drl_defaults}
diff --git a/man/layout_with_sugiyama.Rd b/man/layout_with_sugiyama.Rd
index ea22468df0..5f09a29e39 100644
--- a/man/layout_with_sugiyama.Rd
+++ b/man/layout_with_sugiyama.Rd
@@ -86,19 +86,19 @@ For more details, see the reference below.
 
 ## Data taken from http://tehnick-8.narod.ru/dc_clients/
 DC <- graph_from_literal(
-  "DC++" -+ "LinuxDC++":"BCDC++":"EiskaltDC++":"StrongDC++":"DiCe!++",
-  "LinuxDC++" -+ "FreeDC++", "BCDC++" -+ "StrongDC++",
-  "FreeDC++" -+ "BMDC++":"EiskaltDC++",
-  "StrongDC++" -+ "AirDC++":"zK++":"ApexDC++":"TkDC++",
-  "StrongDC++" -+ "StrongDC++ SQLite":"RSX++",
-  "ApexDC++" -+ "FlylinkDC++ ver <= 4xx",
-  "ApexDC++" -+ "ApexDC++ Speed-Mod":"DiCe!++",
-  "StrongDC++ SQLite" -+ "FlylinkDC++ ver >= 5xx",
-  "ApexDC++ Speed-Mod" -+ "FlylinkDC++ ver <= 4xx",
-  "ApexDC++ Speed-Mod" -+ "GreylinkDC++",
-  "FlylinkDC++ ver <= 4xx" -+ "FlylinkDC++ ver >= 5xx",
-  "FlylinkDC++ ver <= 4xx" -+ AvaLink,
-  "GreylinkDC++" -+ AvaLink:"RayLinkDC++":"SparkDC++":PeLink
+  "DC++" - +"LinuxDC++":"BCDC++":"EiskaltDC++":"StrongDC++":"DiCe!++",
+  "LinuxDC++" - +"FreeDC++", "BCDC++" - +"StrongDC++",
+  "FreeDC++" - +"BMDC++":"EiskaltDC++",
+  "StrongDC++" - +"AirDC++":"zK++":"ApexDC++":"TkDC++",
+  "StrongDC++" - +"StrongDC++ SQLite":"RSX++",
+  "ApexDC++" - +"FlylinkDC++ ver <= 4xx",
+  "ApexDC++" - +"ApexDC++ Speed-Mod":"DiCe!++",
+  "StrongDC++ SQLite" - +"FlylinkDC++ ver >= 5xx",
+  "ApexDC++ Speed-Mod" - +"FlylinkDC++ ver <= 4xx",
+  "ApexDC++ Speed-Mod" - +"GreylinkDC++",
+  "FlylinkDC++ ver <= 4xx" - +"FlylinkDC++ ver >= 5xx",
+  "FlylinkDC++ ver <= 4xx" - +AvaLink,
+  "GreylinkDC++" - +AvaLink:"RayLinkDC++":"SparkDC++":PeLink
 )
 
 ## Use edge types
@@ -165,36 +165,36 @@ plot(lay2$extd_graph, vertex.label.cex = 0.5)
 ## Applications 9, 305--325 (2005).
 
 ex <- graph_from_literal(
-  0 -+ 29:6:5:20:4,
-  1 -+ 12,
-  2 -+ 23:8,
-  3 -+ 4,
+  0 - +29:6:5:20:4,
+  1 - +12,
+  2 - +23:8,
+  3 - +4,
   4,
-  5 -+ 2:10:14:26:4:3,
-  6 -+ 9:29:25:21:13,
+  5 - +2:10:14:26:4:3,
+  6 - +9:29:25:21:13,
   7,
-  8 -+ 20:16,
-  9 -+ 28:4,
-  10 -+ 27,
-  11 -+ 9:16,
-  12 -+ 9:19,
-  13 -+ 20,
-  14 -+ 10,
-  15 -+ 16:27,
-  16 -+ 27,
-  17 -+ 3,
-  18 -+ 13,
-  19 -+ 9,
-  20 -+ 4,
-  21 -+ 22,
-  22 -+ 8:9,
-  23 -+ 9:24,
-  24 -+ 12:15:28,
-  25 -+ 11,
-  26 -+ 18,
-  27 -+ 13:19,
-  28 -+ 7,
-  29 -+ 25
+  8 - +20:16,
+  9 - +28:4,
+  10 - +27,
+  11 - +9:16,
+  12 - +9:19,
+  13 - +20,
+  14 - +10,
+  15 - +16:27,
+  16 - +27,
+  17 - +3,
+  18 - +13,
+  19 - +9,
+  20 - +4,
+  21 - +22,
+  22 - +8:9,
+  23 - +9:24,
+  24 - +12:15:28,
+  25 - +11,
+  26 - +18,
+  27 - +13:19,
+  28 - +7,
+  29 - +25
 )
 
 layers <- list(
diff --git a/man/reverse_edges.Rd b/man/reverse_edges.Rd
index c4afc1e66c..37bc5bbc38 100644
--- a/man/reverse_edges.Rd
+++ b/man/reverse_edges.Rd
@@ -28,7 +28,7 @@ all edges, this operation is also known as graph transpose.
 }
 \examples{
 
-g <- make_graph(~ 1 -+ 2, 2 -+ 3, 3 -+ 4)
+g <- make_graph(~ 1 - +2, 2 - +3, 3 - +4)
 reverse_edges(g, 2)
 }
 \seealso{
diff --git a/man/st_cuts.Rd b/man/st_cuts.Rd
index 970295a3a5..20fb618e09 100644
--- a/man/st_cuts.Rd
+++ b/man/st_cuts.Rd
@@ -34,13 +34,13 @@ removing these edges from \eqn{G} there is no directed path from \eqn{s} to
 \examples{
 
 # A very simple graph
-g <- graph_from_literal(a - +b - +c - +d - +e)
+g <- graph_from_literal(a -+ b -+ c -+ d -+ e)
 st_cuts(g, source = "a", target = "e")
 
 # A somewhat more difficult graph
 g2 <- graph_from_literal(
-  s - -+a:b, a:b - -+t,
-  a - -+1:2:3, 1:2:3 - -+b
+  s --+ a:b, a:b --+ t,
+  a --+ 1:2:3, 1:2:3 --+ b
 )
 st_cuts(g2, source = "s", target = "t")
 }
diff --git a/man/st_min_cuts.Rd b/man/st_min_cuts.Rd
index 8a58a974cd..efa7d1df96 100644
--- a/man/st_min_cuts.Rd
+++ b/man/st_min_cuts.Rd
@@ -49,8 +49,8 @@ An \eqn{(s,t)}-cut is minimum if it is of the smallest possible size.
 
 # A difficult graph, from the Provan-Shier paper
 g <- graph_from_literal(
-  s - -+a:b, a:b - -+t,
-  a - -+1:2:3:4:5, 1:2:3:4:5 - -+b
+  s --+ a:b, a:b --+ t,
+  a --+ 1:2:3:4:5, 1:2:3:4:5 --+ b
 )
 st_min_cuts(g, source = "s", target = "t")
 }
diff --git a/man/vertex.shape.pie.Rd b/man/vertex.shape.pie.Rd
index 5c59f6413c..41f2901937 100644
--- a/man/vertex.shape.pie.Rd
+++ b/man/vertex.shape.pie.Rd
@@ -29,12 +29,14 @@ slices.} }
 \examples{
 
 g <- make_ring(10)
-values <- lapply(1:10, function(x) sample(1:10,3))
+values <- lapply(1:10, function(x) sample(1:10, 3))
 
 \dontshow{if (interactive()) withAutoprint(\{ # examplesIf}
-plot(g, vertex.shape = "pie", vertex.pie = values,
-     vertex.pie.color = list(heat.colors(5)),
-     vertex.size = seq(10, 30, length.out = 10), vertex.label = NA)
+plot(g,
+  vertex.shape = "pie", vertex.pie = values,
+  vertex.pie.color = list(heat.colors(5)),
+  vertex.size = seq(10, 30, length.out = 10), vertex.label = NA
+)
 \dontshow{\}) # examplesIf}
 }
 \seealso{

From eee5f966a1b71fdbcb80d6912b8b358186bd56b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= <maelle.salmon@yahoo.se>
Date: Thu, 6 Mar 2025 09:59:23 +0100
Subject: [PATCH 4/5] error

---
 R/motifs.R | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/R/motifs.R b/R/motifs.R
index 5dbeb61ae5..c569afdd9b 100644
--- a/R/motifs.R
+++ b/R/motifs.R
@@ -132,10 +132,7 @@ motifs <- function(graph, size = 3, cut.prob = NULL) {
   if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob)
 
   if (!is.null(cut.prob) && length(cut.prob) != size) {
-    cut.prob <- c(
-      cut.prob[-length(cut.prob)],
-      rep(cut.prob[-length(cut.prob)], length(cut.prob) - 1)
-    )
+    cli::cli_abort("{arg cut.prob} must be the same length as {.arg size}")
   }
 
   on.exit(.Call(R_igraph_finalizer))
@@ -178,10 +175,7 @@ count_motifs <- function(graph, size = 3, cut.prob = NULL) {
   if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob)
 
   if (!is.null(cut.prob) && length(cut.prob) != size) {
-    cut.prob <- c(
-      cut.prob[-length(cut.prob)],
-      rep(cut.prob[-length(cut.prob)], length(cut.prob) - 1)
-    )
+    cli::cli_abort("{arg cut.prob} must be the same length as {.arg size}")
   }
 
   on.exit(.Call(R_igraph_finalizer))
@@ -234,10 +228,7 @@ sample_motifs <- function(
   if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob)
 
   if (!is.null(cut.prob) && length(cut.prob) != size) {
-    cut.prob <- c(
-      cut.prob[-length(cut.prob)],
-      rep(cut.prob[-length(cut.prob)], length(cut.prob) - 1)
-    )
+    cli::cli_abort("{arg cut.prob} must be the same length as {.arg size}")
   }
 
   if (is.null(sample)) {

From 4b99054aec0ce2d1820bf44e403f509078c08de7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= <maelle.salmon@yahoo.se>
Date: Thu, 6 Mar 2025 10:03:33 +0100
Subject: [PATCH 5/5] fix test

---
 tests/testthat/test-motifs.R | 88 ++++++++++++++++++++++++++++++++++--
 1 file changed, 84 insertions(+), 4 deletions(-)

diff --git a/tests/testthat/test-motifs.R b/tests/testthat/test-motifs.R
index fc7b7d513f..bdbcd1e39b 100644
--- a/tests/testthat/test-motifs.R
+++ b/tests/testthat/test-motifs.R
@@ -31,14 +31,94 @@ test_that("motifs works", {
   m0 <- motifs(gnp, cut.prob = c(1 / 3, 0, 0))
   m1 <- motifs(gnp, cut.prob = c(0, 1 / 3, 0))
   m2 <- motifs(gnp, cut.prob = c(0, 0, 1 / 3))
-  expect_equal(m0 / m, c(NA, NA, 0.653972107372707, NA, 0.653993015279859, 0.612244897959184, 0.657514670174019, 0.63013698630137, NaN, 0.538461538461538, NaN, 0.565217391304348, NaN, NaN, NaN, NaN))
-  expect_equal(m1 / m, c(NA, NA, 0.669562138856225, NA, 0.66808158454082, 0.73469387755102, 0.670819000404694, 0.657534246575342, NaN, 0.769230769230769, NaN, 0.739130434782609, NaN, NaN, NaN, NaN))
-  expect_equal(m2 / m, c(NA, NA, 0.666451718949538, NA, 0.665291458452201, 0.591836734693878, 0.666683528935654, 0.671232876712329, NaN, 0.753846153846154, NaN, 0.565217391304348, NaN, NaN, NaN, NaN))
+  expect_equal(
+    m0 / m,
+    c(
+      NA,
+      NA,
+      0.672381747145621,
+      NA,
+      0.674984795380304,
+      0.63265306122449,
+      0.675738567381627,
+      0.698630136986301,
+      NaN,
+      0.784615384615385,
+      NaN,
+      0.608695652173913,
+      NaN,
+      NaN,
+      NaN,
+      NaN
+    )
+  )
+  expect_equal(
+    m1 / m,
+    c(
+      NA,
+      NA,
+      0.66650229488298,
+      NA,
+      0.666263300123518,
+      0.63265306122449,
+      0.66845406717928,
+      0.671232876712329,
+      NaN,
+      0.6,
+      NaN,
+      0.695652173913043,
+      NaN,
+      NaN,
+      NaN,
+      NaN
+    )
+  )
+  expect_equal(
+    m2 / m,
+    c(
+      NA,
+      NA,
+      0.663265435142687,
+      NA,
+      0.667442050021631,
+      0.653061224489796,
+      0.666278834479968,
+      0.657534246575342,
+      NaN,
+      0.661538461538462,
+      NaN,
+      0.652173913043478,
+      NaN,
+      NaN,
+      NaN,
+      NaN
+    )
+  )
 
   m3 <- motifs(gnp, cut.prob = c(0, 1 / 3, 1 / 3))
   m4 <- motifs(gnp, cut.prob = c(1 / 3, 1 / 3, 0))
   m5 <- motifs(gnp, cut.prob = c(1 / 3, 1 / 3, 0))
-  expect_equal(m3 / m, c(NA, NA, 0.445611905574732, NA, 0.442789875290769, 0.448979591836735, 0.444695973290166, 0.424657534246575, NaN, 0.369230769230769, NaN, 0.608695652173913, NaN, NaN, NaN, NaN))
+  expect_equal(
+    m3 / m,
+    c(
+      NA,
+      NA,
+      0.439062322193984,
+      NA,
+      0.441742794264253,
+      0.408163265306122,
+      0.44431657223796,
+      0.438356164383562,
+      NaN,
+      0.415384615384615,
+      NaN,
+      0.478260869565217,
+      NaN,
+      NaN,
+      NaN,
+      NaN
+    )
+  )
 
   expect_equal(m4 / m, c(NA, NA, 0.439770385262173, NA, 0.441040560282398, 0.224489795918367, 0.438752023472278, 0.534246575342466, NaN, 0.430769230769231, NaN, 0.391304347826087, NaN, NaN, NaN, NaN))