Skip to content

Commit

Permalink
Fix #152
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Nov 6, 2023
1 parent 1ed04e9 commit 15ec6c3
Show file tree
Hide file tree
Showing 17 changed files with 249 additions and 16 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Imports:
cli,
dplyr (>= 0.8.5),
igraph (>= 1.3.0),
lifecycle,
magrittr,
pillar,
R6,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion R/context.R
Original file line number Diff line number Diff line change
Expand Up @@ -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())
#'
Expand Down
36 changes: 26 additions & 10 deletions R/play.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand All @@ -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
#'
Expand Down
1 change: 1 addition & 0 deletions R/tidygraph-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions man/figures/lifecycle-archived.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-defunct.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-deprecated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-experimental.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-maturing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-questioning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-soft-deprecated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions man/figures/lifecycle-stable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-superseded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions man/sampling_games.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/with_graph.Rd

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

0 comments on commit 15ec6c3

Please sign in to comment.