Skip to content

Commit

Permalink
Fix #166
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Oct 30, 2023
1 parent 5c72624 commit 759053d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions R/group.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()]
Expand Down
2 changes: 1 addition & 1 deletion man/centrality.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/graph_measures.Rd

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

4 changes: 3 additions & 1 deletion man/group_graph.Rd

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

0 comments on commit 759053d

Please sign in to comment.