From b76b67e72abaedecf55b067762c825e4eba32d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Fri, 16 Jun 2023 11:50:21 +0200 Subject: [PATCH 1/2] rm igraph::estimate_ functions that will soon be deprecated --- DESCRIPTION | 2 +- NAMESPACE | 3 --- R/centrality.R | 33 +++++++++++++-------------------- man/centrality.Rd | 6 +++--- man/graph_measures.Rd | 2 +- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 335218f..c32dfd2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,7 @@ Description: A graph, while not "tidy" in itself, can be thought of as two tidy a lot of common graph algorithms. License: MIT + file LICENSE Encoding: UTF-8 -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Roxygen: list(markdown = TRUE) Imports: tibble, diff --git a/NAMESPACE b/NAMESPACE index a1c805b..74c56da 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -459,9 +459,6 @@ importFrom(igraph,edge_connectivity) importFrom(igraph,ego) importFrom(igraph,ego_size) importFrom(igraph,eigen_centrality) -importFrom(igraph,estimate_betweenness) -importFrom(igraph,estimate_closeness) -importFrom(igraph,estimate_edge_betweenness) importFrom(igraph,girth) importFrom(igraph,gorder) importFrom(igraph,graph_attr) diff --git a/R/centrality.R b/R/centrality.R index 11bfbfb..9f7016c 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -74,8 +74,8 @@ centrality_authority <- function(weights = NULL, scale = TRUE, options = igraph: } authority_score(graph = .G(), scale = scale, weights = weights, options = options)$vector } -#' @describeIn centrality Wrapper for [igraph::betweenness()] and [igraph::estimate_betweenness()] -#' @importFrom igraph V betweenness estimate_betweenness +#' @describeIn centrality Wrapper for [igraph::betweenness()] +#' @importFrom igraph V betweenness #' @importFrom rlang quos #' @export centrality_betweenness <- function(weights = NULL, directed = TRUE, cutoff = -1, normalized = FALSE) { @@ -86,11 +86,9 @@ centrality_betweenness <- function(weights = NULL, directed = TRUE, cutoff = -1, if (is.null(weights)) { weights <- NA } - if (is.null(cutoff)) { - betweenness(graph = graph, v = V(graph), directed = directed, weights = weights, normalized = normalized) - } else { - estimate_betweenness(graph = graph, vids = V(graph), directed = directed, cutoff = cutoff, weights = weights) - } + cutoff <- cutoff %||% -1 + betweenness(graph = graph, v = V(graph), directed = directed, cutoff = cutoff, weights = weights, normalized = normalized) + } #' @describeIn centrality Wrapper for [igraph::power_centrality()] #' @importFrom igraph V power_centrality @@ -100,8 +98,8 @@ centrality_power <- function(exponent = 1, rescale = FALSE, tol = 1e-7, loops = graph <- .G() power_centrality(graph = graph, nodes = V(graph), exponent = exponent, loops = loops, rescale = rescale, tol = tol) } -#' @describeIn centrality Wrapper for [igraph::closeness()] and [igraph::estimate_closeness()] -#' @importFrom igraph V closeness estimate_closeness +#' @describeIn centrality Wrapper for [igraph::closeness()] +#' @importFrom igraph V closeness #' @importFrom rlang quos #' @export centrality_closeness <- function(weights = NULL, mode = 'out', normalized = FALSE, cutoff = NULL) { @@ -112,11 +110,8 @@ centrality_closeness <- function(weights = NULL, mode = 'out', normalized = FALS if (is.null(weights)) { weights <- NA } - if (is.null(cutoff)) { - closeness(graph = graph, vids = V(graph), mode = mode, weights = weights, normalized = normalized) - } else { - estimate_closeness(graph = graph, vids = V(graph), mode = mode, cutoff = cutoff, weights = weights, normalized = normalized) - } + cutoff <- cutoff %||% -1 + closeness(graph = graph, v = V(graph), mode = mode, cutoff = cutoff, weights = weights, normalized = normalized) } #' @describeIn centrality Wrapper for [igraph::eigen_centrality()] #' @importFrom igraph eigen_centrality @@ -183,7 +178,7 @@ centrality_degree <- function(weights = NULL, mode = 'out', loops = TRUE, normal } } #' @describeIn centrality Wrapper for [igraph::edge_betweenness()] -#' @importFrom igraph edge_betweenness estimate_edge_betweenness E +#' @importFrom igraph edge_betweenness E #' @importFrom rlang quos #' @export centrality_edge_betweenness <- function(weights = NULL, directed = TRUE, cutoff = NULL) { @@ -194,11 +189,9 @@ centrality_edge_betweenness <- function(weights = NULL, directed = TRUE, cutoff if (is.null(weights)) { weights <- NA } - if (is.null(cutoff)) { - edge_betweenness(graph = graph, e = E(graph), directed = directed, weights = weights) - } else { - estimate_edge_betweenness(graph = graph, e = E(graph), directed = directed, cutoff = cutoff, weights = weights) - } + + cutoff <- cutoff %||% -1 + edge_betweenness(graph = graph, e = E(graph), directed = directed, cutoff = cutoff, weights = weights) } #' @describeIn centrality Manually specify your centrality score using the `netrankr` framework (`netrankr`) #' @param relation The indirect relation measure type to be used in `netrankr::indirect_relations` diff --git a/man/centrality.Rd b/man/centrality.Rd index 366266a..8ac2c08 100644 --- a/man/centrality.Rd +++ b/man/centrality.Rd @@ -196,13 +196,13 @@ manual mode for specifying more-or-less any centrality score. \itemize{ \item \code{centrality_alpha()}: Wrapper for \code{\link[igraph:alpha_centrality]{igraph::alpha_centrality()}} -\item \code{centrality_authority()}: Wrapper for \code{\link[igraph:authority_score]{igraph::authority_score()}} +\item \code{centrality_authority()}: Wrapper for \code{\link[igraph:hub_score]{igraph::authority_score()}} -\item \code{centrality_betweenness()}: Wrapper for \code{\link[igraph:betweenness]{igraph::betweenness()}} and \code{\link[igraph:betweenness]{igraph::estimate_betweenness()}} +\item \code{centrality_betweenness()}: Wrapper for \code{\link[igraph:betweenness]{igraph::betweenness()}} \item \code{centrality_power()}: Wrapper for \code{\link[igraph:power_centrality]{igraph::power_centrality()}} -\item \code{centrality_closeness()}: Wrapper for \code{\link[igraph:closeness]{igraph::closeness()}} and \code{\link[igraph:closeness]{igraph::estimate_closeness()}} +\item \code{centrality_closeness()}: Wrapper for \code{\link[igraph:closeness]{igraph::closeness()}} \item \code{centrality_eigen()}: Wrapper for \code{\link[igraph:eigen_centrality]{igraph::eigen_centrality()}} diff --git a/man/graph_measures.Rd b/man/graph_measures.Rd index d28702b..407be1e 100644 --- a/man/graph_measures.Rd +++ b/man/graph_measures.Rd @@ -125,7 +125,7 @@ them. \item \code{graph_assortativity()}: Measures the propensity of similar nodes to be connected. Wraps \code{\link[igraph:assortativity]{igraph::assortativity()}} -\item \code{graph_automorphisms()}: Calculate the number of automorphisms of the graph. Wraps \code{\link[igraph:automorphisms]{igraph::automorphisms()}} +\item \code{graph_automorphisms()}: Calculate the number of automorphisms of the graph. Wraps \code{\link[igraph:count_automorphisms]{igraph::automorphisms()}} \item \code{graph_clique_num()}: Get the size of the largest clique. Wraps \code{\link[igraph:cliques]{igraph::clique_num()}} From c1ca40442ec645815316c3755000c4ffa9a765f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Fri, 16 Jun 2023 11:56:51 +0200 Subject: [PATCH 2/2] fix argument name --- R/centrality.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/centrality.R b/R/centrality.R index 9f7016c..c8fb089 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -111,7 +111,7 @@ centrality_closeness <- function(weights = NULL, mode = 'out', normalized = FALS weights <- NA } cutoff <- cutoff %||% -1 - closeness(graph = graph, v = V(graph), mode = mode, cutoff = cutoff, weights = weights, normalized = normalized) + closeness(graph = graph, vids = V(graph), mode = mode, cutoff = cutoff, weights = weights, normalized = normalized) } #' @describeIn centrality Wrapper for [igraph::eigen_centrality()] #' @importFrom igraph eigen_centrality