diff --git a/DESCRIPTION b/DESCRIPTION index 6e28352..6d16731 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,6 +19,7 @@ Imports: cli, dplyr (>= 0.8.5), igraph (>= 1.3.0), + lifecycle, magrittr, pillar, R6, diff --git a/NAMESPACE b/NAMESPACE index df24a69..60779c8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -315,6 +315,8 @@ export(play_fitness) export(play_fitness_power) export(play_forestfire) export(play_geometry) +export(play_gnm) +export(play_gnp) export(play_growing) export(play_islands) export(play_preference) @@ -549,6 +551,7 @@ importFrom(igraph,vertex_connectivity) importFrom(igraph,which_loop) importFrom(igraph,which_multiple) importFrom(igraph,which_mutual) +importFrom(lifecycle,deprecated) importFrom(magrittr,"%>%") importFrom(pillar,style_subtle) importFrom(pillar,tbl_format_footer) diff --git a/NEWS.md b/NEWS.md index 4bfcf65..46073f3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ the edges are encoded as a character (#147) * Added `node_is_connected()` to test whether a node is connected to a set of nodes (#165) +* Deprecated `play_erdos_renyi()` in favour of `play_gnm()` and `play_gnp()` + (#152) # tidygraph 1.2.3 diff --git a/R/context.R b/R/context.R index c4e1777..84ec922 100644 --- a/R/context.R +++ b/R/context.R @@ -151,7 +151,7 @@ NULL #' @export #' #' @examples -#' gr <- play_erdos_renyi(10, 0.3) +#' gr <- play_gnp(10, 0.3) #' #' with_graph(gr, centrality_degree()) #' diff --git a/R/play.R b/R/play.R index 85dece3..f88bc5e 100644 --- a/R/play.R +++ b/R/play.R @@ -143,17 +143,19 @@ play_fitness <- function(m, out_fit, in_fit = NULL, loops = FALSE, multiple = FA play_fitness_power <- function(n, m, out_exp, in_exp = -1, loops = FALSE, multiple = FALSE, correct = TRUE) { as_tbl_graph(sample_fitness_pl(n, m, out_exp, in_exp, loops, multiple, correct)) } -#' @describeIn sampling_games Create graphs with a fixed edge probability or -#' count. See [igraph::sample_gnp()] and [igraph::sample_gnm()] -#' @importFrom igraph sample_gnm sample_gnp +#' @describeIn sampling_games Create graphs with a fixed edge count. See +#' [igraph::sample_gnm()] +#' @importFrom igraph sample_gnm #' @export -play_erdos_renyi <- function(n, p, m, directed = TRUE, loops = FALSE) { - if (missing(p)) { - as_tbl_graph(sample_gnm(n, m, directed, loops)) - } else { - if (!missing(m)) cli::cli_warn('Ignoring {.arg m} as {.arg p} is provided') - as_tbl_graph(sample_gnp(n, p, directed, loops)) - } +play_gnm <- function(n, m, directed = TRUE, loops = FALSE) { + as_tbl_graph(sample_gnm(n, m, directed, loops)) +} +#' @describeIn sampling_games Create graphs with a fixed edge probability. See +#' [igraph::sample_gnp()] +#' @importFrom igraph sample_gnp +#' @export +play_gnp <- function(n, p, directed = TRUE, loops = FALSE) { + as_tbl_graph(sample_gnp(n, p, directed, loops)) } #' @describeIn sampling_games Create graphs by positioning nodes on a plane or #' torus and connecting nearby ones. See [igraph::sample_grg()] @@ -162,6 +164,20 @@ play_erdos_renyi <- function(n, p, m, directed = TRUE, loops = FALSE) { play_geometry <- function(n, radius, torus = FALSE) { as_tbl_graph(sample_grg(n, radius, torus, TRUE)) } +#' @describeIn sampling_games `r lifecycle::badge('deprecated')` Create graphs +#' with a fixed edge probability or count. See [igraph::sample_gnp()] and +#' [igraph::sample_gnm()] +#' @importFrom igraph sample_gnm sample_gnp +#' @export +play_erdos_renyi <- function(n, p, m, directed = TRUE, loops = FALSE) { + if (missing(p)) { + lifecycle::deprecate_soft("1.3.0", "play_erdos_renyi()", "play_gnm()") + as_tbl_graph(sample_gnm(n, m, directed, loops)) + } else { + lifecycle::deprecate_soft("1.3.0", "play_erdos_renyi()", "play_gnp()") + as_tbl_graph(sample_gnp(n, p, directed, loops)) + } +} #' Graph games based on evolution #' diff --git a/R/tidygraph-package.R b/R/tidygraph-package.R index 8adff4b..90d4ab6 100644 --- a/R/tidygraph-package.R +++ b/R/tidygraph-package.R @@ -4,6 +4,7 @@ # The following block is used by usethis to automatically manage # roxygen namespace tags. Modify with care! ## usethis namespace: start +#' @importFrom lifecycle deprecated #' @useDynLib tidygraph, .registration = TRUE ## usethis namespace: end NULL diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg new file mode 100644 index 0000000..745ab0c --- /dev/null +++ b/man/figures/lifecycle-archived.svg @@ -0,0 +1,21 @@ + + lifecycle: archived + + + + + + + + + + + + + + + lifecycle + + archived + + diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg new file mode 100644 index 0000000..d5c9559 --- /dev/null +++ b/man/figures/lifecycle-defunct.svg @@ -0,0 +1,21 @@ + + lifecycle: defunct + + + + + + + + + + + + + + + lifecycle + + defunct + + diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg new file mode 100644 index 0000000..b61c57c --- /dev/null +++ b/man/figures/lifecycle-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg new file mode 100644 index 0000000..5d88fc2 --- /dev/null +++ b/man/figures/lifecycle-experimental.svg @@ -0,0 +1,21 @@ + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg new file mode 100644 index 0000000..897370e --- /dev/null +++ b/man/figures/lifecycle-maturing.svg @@ -0,0 +1,21 @@ + + lifecycle: maturing + + + + + + + + + + + + + + + lifecycle + + maturing + + diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg new file mode 100644 index 0000000..7c1721d --- /dev/null +++ b/man/figures/lifecycle-questioning.svg @@ -0,0 +1,21 @@ + + lifecycle: questioning + + + + + + + + + + + + + + + lifecycle + + questioning + + diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg new file mode 100644 index 0000000..9c166ff --- /dev/null +++ b/man/figures/lifecycle-soft-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: soft-deprecated + + + + + + + + + + + + + + + lifecycle + + soft-deprecated + + diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg new file mode 100644 index 0000000..9bf21e7 --- /dev/null +++ b/man/figures/lifecycle-stable.svg @@ -0,0 +1,29 @@ + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg new file mode 100644 index 0000000..db8d757 --- /dev/null +++ b/man/figures/lifecycle-superseded.svg @@ -0,0 +1,21 @@ + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/man/sampling_games.Rd b/man/sampling_games.Rd index fbfa32f..37bde08 100644 --- a/man/sampling_games.Rd +++ b/man/sampling_games.Rd @@ -6,8 +6,10 @@ \alias{play_dotprod} \alias{play_fitness} \alias{play_fitness_power} -\alias{play_erdos_renyi} +\alias{play_gnm} +\alias{play_gnp} \alias{play_geometry} +\alias{play_erdos_renyi} \title{Graph games based on direct sampling} \usage{ play_degree(out_degree, in_degree = NULL, method = "simple") @@ -26,9 +28,13 @@ play_fitness_power( correct = TRUE ) -play_erdos_renyi(n, p, m, directed = TRUE, loops = FALSE) +play_gnm(n, m, directed = TRUE, loops = FALSE) + +play_gnp(n, p, directed = TRUE, loops = FALSE) play_geometry(n, radius, torus = FALSE) + +play_erdos_renyi(n, p, m, directed = TRUE, loops = FALSE) } \arguments{ \item{out_degree, in_degree}{The degrees of each node in the graph} @@ -83,12 +89,19 @@ proportional to terminal node fitness scores. See \code{\link[igraph:sample_fitn \item \code{play_fitness_power()}: Create graphs with an expected power-law degree distribution. See \code{\link[igraph:sample_fitness_pl]{igraph::sample_fitness_pl()}} -\item \code{play_erdos_renyi()}: Create graphs with a fixed edge probability or -count. See \code{\link[igraph:sample_gnp]{igraph::sample_gnp()}} and \code{\link[igraph:sample_gnm]{igraph::sample_gnm()}} +\item \code{play_gnm()}: Create graphs with a fixed edge count. See +\code{\link[igraph:sample_gnm]{igraph::sample_gnm()}} + +\item \code{play_gnp()}: Create graphs with a fixed edge probability. See +\code{\link[igraph:sample_gnp]{igraph::sample_gnp()}} \item \code{play_geometry()}: Create graphs by positioning nodes on a plane or torus and connecting nearby ones. See \code{\link[igraph:sample_grg]{igraph::sample_grg()}} +\item \code{play_erdos_renyi()}: \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Create graphs +with a fixed edge probability or count. See \code{\link[igraph:sample_gnp]{igraph::sample_gnp()}} and +\code{\link[igraph:sample_gnm]{igraph::sample_gnm()}} + }} \examples{ plot(play_erdos_renyi(20, 0.3)) diff --git a/man/with_graph.Rd b/man/with_graph.Rd index f1556c2..644a0ed 100644 --- a/man/with_graph.Rd +++ b/man/with_graph.Rd @@ -23,7 +23,7 @@ want to use an algorithm outside of the tidygraph framework you can use being evaluated. } \examples{ -gr <- play_erdos_renyi(10, 0.3) +gr <- play_gnp(10, 0.3) with_graph(gr, centrality_degree())