diff --git a/NEWS.md b/NEWS.md index f0f56ee..de39cb7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # tidygraph (development version) +* Add `resolution` argument to `group_louvrain()` to mirror the igraph function + # tidygraph 1.2.3 * Small updates to work with new versions of igraph and dplyr diff --git a/R/group.R b/R/group.R index 5060e8d..3b95aa8 100644 --- a/R/group.R +++ b/R/group.R @@ -22,6 +22,7 @@ #' @param trials Number of times partition of the network should be attempted #' @param steps The number of steps in the random walks #' @param options Settings passed on to `igraph::arpack()` +#' @param resolution Resolution of the modularity function used internally in the algorithm #' @param ... arguments passed on to [igraph::cluster_spinglass()] #' #' @return a numeric vector with the membership for each node in the graph. The @@ -137,14 +138,14 @@ group_leading_eigen <- function(weights = NULL, steps = -1, label = NULL, option #' @describeIn group_graph Group nodes by multilevel optimisation of modularity using [igraph::cluster_louvain()] #' @importFrom igraph membership cluster_louvain #' @export -group_louvain <- function(weights = NULL) { +group_louvain <- function(weights = NULL, resolution = 1) { expect_nodes() weights <- enquo(weights) weights <- eval_tidy(weights, .E()) if (is.null(weights)) { weights <- NA } - group <- as.integer(membership(cluster_louvain(graph = .G(), weights = weights))) + group <- as.integer(membership(cluster_louvain(graph = .G(), weights = weights, resolution = resolution))) desc_enumeration(group) } #' @describeIn group_graph Group nodes by optimising the moldularity score using [igraph::cluster_optimal()] diff --git a/man/centrality.Rd b/man/centrality.Rd index 8ac2c08..a1870d1 100644 --- a/man/centrality.Rd +++ b/man/centrality.Rd @@ -196,7 +196,7 @@ 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:hub_score]{igraph::authority_score()}} +\item \code{centrality_authority()}: Wrapper for \code{\link[igraph:authority_score]{igraph::authority_score()}} \item \code{centrality_betweenness()}: Wrapper for \code{\link[igraph:betweenness]{igraph::betweenness()}} diff --git a/man/graph_measures.Rd b/man/graph_measures.Rd index 407be1e..d28702b 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:count_automorphisms]{igraph::automorphisms()}} +\item \code{graph_automorphisms()}: Calculate the number of automorphisms of the graph. Wraps \code{\link[igraph:automorphisms]{igraph::automorphisms()}} \item \code{graph_clique_num()}: Get the size of the largest clique. Wraps \code{\link[igraph:cliques]{igraph::clique_num()}} diff --git a/man/group_graph.Rd b/man/group_graph.Rd index 2acfe6a..4fce573 100644 --- a/man/group_graph.Rd +++ b/man/group_graph.Rd @@ -33,7 +33,7 @@ group_leading_eigen( n_groups = NULL ) -group_louvain(weights = NULL) +group_louvain(weights = NULL, resolution = 1) group_optimal(weights = NULL) @@ -68,6 +68,8 @@ initial groups. Will be evaluated in the context of the node data.} \item{options}{Settings passed on to \code{igraph::arpack()}} +\item{resolution}{Resolution of the modularity function used internally in the algorithm} + \item{...}{arguments passed on to \code{\link[igraph:cluster_spinglass]{igraph::cluster_spinglass()}}} } \value{