From d25bc7a727a2d837c68b9f6131277eeba05a20ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Fri, 16 Jun 2023 10:11:16 +0200 Subject: [PATCH 1/2] docs: undeprecate neighborhood() --- R/structural.properties.R | 15 +++++++++++++-- R/zzz-deprecate.R | 2 -- man/ego.Rd | 16 ++++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/R/structural.properties.R b/R/structural.properties.R index 2598fa20c96..f1ed4e1513d 100644 --- a/R/structural.properties.R +++ b/R/structural.properties.R @@ -1139,7 +1139,7 @@ ego_size <- function(graph, order = 1, nodes = V(graph), #' `ego_size()` returns the size of the neighborhoods of the given order, #' for each given vertex. #' -#' `ego()` returns the vertices belonging to the neighborhoods of the given +#' `ego()`/`neighborhood()` (synonyms) returns the vertices belonging to the neighborhoods of the given #' order, for each given vertex. #' #' `make_ego_graph()` is creates (sub)graphs from all neighborhoods of @@ -1165,7 +1165,7 @@ ego_size <- function(graph, order = 1, nodes = V(graph), #' @return #' \itemize{ #' \item{`ego_size()` returns with an integer vector.} -#' \item{`ego()` returns A list of `igraph.vs` or a list of numeric +#' \item{`ego()`/`neighborhood()` (synonyms) returns A list of `igraph.vs` or a list of numeric #' vectors depending on the value of `igraph_opt("return.vs.es")`, #' see details for performance characteristics.} #' \item{`make_ego_graph()` returns with a list of graphs.} @@ -1185,6 +1185,10 @@ ego_size <- function(graph, order = 1, nodes = V(graph), #' ego(g, order = 0, 1:3) #' ego(g, order = 1, 1:3) #' ego(g, order = 2, 1:3) +#' # neighborhood() is an alias of ego() +#' neighborhood(g, order = 0, 1:3) +#' neighborhood(g, order = 1, 1:3) +#' neighborhood(g, order = 2, 1:3) #' #' # attributes are preserved #' V(g)$name <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j") @@ -1220,6 +1224,13 @@ ego <- function(graph, order = 1, nodes = V(graph), res } +#' @export +#' @rdname ego +neighborhood <- function(graph, order = 1, nodes = V(graph), + mode = c("all", "out", "in"), mindist = 0) { + ego(graph, order = order, nodes = nodes, + mode = mode, mindist = mindist) +} #' @rdname ego #' @family structural.properties #' @export diff --git a/R/zzz-deprecate.R b/R/zzz-deprecate.R index 98ef6e532cc..76ff583d58e 100644 --- a/R/zzz-deprecate.R +++ b/R/zzz-deprecate.R @@ -447,8 +447,6 @@ deprecated("mod.matrix", modularity_matrix) #' @export multilevel.community deprecated("multilevel.community", cluster_louvain) -#' @export neighborhood -deprecated("neighborhood", ego) #' @export neighborhood.size deprecated("neighborhood.size", ego_size) #' @export no.clusters diff --git a/man/ego.Rd b/man/ego.Rd index c84294c1ab5..a2f72f55a2f 100644 --- a/man/ego.Rd +++ b/man/ego.Rd @@ -30,6 +30,14 @@ ego( mindist = 0 ) +neighborhood( + graph, + order = 1, + nodes = V(graph), + mode = c("all", "out", "in"), + mindist = 0 +) + make_ego_graph( graph, order = 1, @@ -58,7 +66,7 @@ argument is ignored for undirected graphs.} \value{ \itemize{ \item{\code{ego_size()} returns with an integer vector.} -\item{\code{ego()} returns A list of \code{igraph.vs} or a list of numeric +\item{\code{ego()}/\code{neighborhood()} (synonyms) returns A list of \code{igraph.vs} or a list of numeric vectors depending on the value of \code{igraph_opt("return.vs.es")}, see details for performance characteristics.} \item{\code{make_ego_graph()} returns with a list of graphs.} @@ -78,7 +86,7 @@ is order 1 plus the immediate neighbors of the vertices in order 1, etc. \code{ego_size()} returns the size of the neighborhoods of the given order, for each given vertex. -\code{ego()} returns the vertices belonging to the neighborhoods of the given +\code{ego()}/\code{neighborhood()} (synonyms) returns the vertices belonging to the neighborhoods of the given order, for each given vertex. \code{make_ego_graph()} is creates (sub)graphs from all neighborhoods of @@ -97,6 +105,10 @@ ego_size(g, order = 2, 1:3) ego(g, order = 0, 1:3) ego(g, order = 1, 1:3) ego(g, order = 2, 1:3) +# neighborhood() is an alias of ego() +neighborhood(g, order = 0, 1:3) +neighborhood(g, order = 1, 1:3) +neighborhood(g, order = 2, 1:3) # attributes are preserved V(g)$name <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j") From a022d1613eef016dd071ec84b810e3e62be0364c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Fri, 16 Jun 2023 10:31:13 +0200 Subject: [PATCH 2/2] simpler --- R/structural.properties.R | 7 ++----- man/ego.Rd | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/R/structural.properties.R b/R/structural.properties.R index f1ed4e1513d..8f6e94a0149 100644 --- a/R/structural.properties.R +++ b/R/structural.properties.R @@ -1130,6 +1130,7 @@ ego_size <- function(graph, order = 1, nodes = V(graph), #' #' These functions find the vertices not farther than a given limit from #' another fixed vertex, these are called the neighborhood of the vertex. +#' Note that `ego()` and `neighborhood()` are synonyms, aliases. #' #' The neighborhood of a given order `r` of a vertex `v` includes all #' vertices which are closer to `v` than the order. I.e. order 0 is always @@ -1226,11 +1227,7 @@ ego <- function(graph, order = 1, nodes = V(graph), #' @export #' @rdname ego -neighborhood <- function(graph, order = 1, nodes = V(graph), - mode = c("all", "out", "in"), mindist = 0) { - ego(graph, order = order, nodes = nodes, - mode = mode, mindist = mindist) -} +neighborhood <- ego #' @rdname ego #' @family structural.properties #' @export diff --git a/man/ego.Rd b/man/ego.Rd index a2f72f55a2f..adc0eabb391 100644 --- a/man/ego.Rd +++ b/man/ego.Rd @@ -76,6 +76,7 @@ see details for performance characteristics.} \description{ These functions find the vertices not farther than a given limit from another fixed vertex, these are called the neighborhood of the vertex. +Note that \code{ego()} and \code{neighborhood()} are synonyms, aliases. } \details{ The neighborhood of a given order \code{r} of a vertex \code{v} includes all