Skip to contents

This function tries to find dense subgraph, also called communities in graphs via directly optimizing a modularity score.

Usage

cluster_fast_greedy(
  graph,
  merges = TRUE,
  modularity = TRUE,
  membership = TRUE,
  weights = NULL
)

Arguments

graph

The input graph

merges

Logical scalar, whether to return the merge matrix.

modularity

Logical scalar, whether to return a vector containing the modularity after each merge.

membership

Logical scalar, whether to calculate the membership vector corresponding to the maximum modularity score, considering all possible community structures along the merges.

weights

The weights of the edges. It must be a positive numeric vector, NULL or NA. If it is NULL and the input graph has a ‘weight’ edge attribute, then that attribute will be used. If NULL and no such attribute is present, then the edges will have equal weights. Set this to NA if the graph was a ‘weight’ edge attribute, but you don't want to use it for community detection. A larger edge weight means a stronger connection for this function.

Value

cluster_fast_greedy() returns a communities()

object, please see the communities() manual page for details.

Details

This function implements the fast greedy modularity optimization algorithm for finding community structure, see A Clauset, MEJ Newman, C Moore: Finding community structure in very large networks, http://www.arxiv.org/abs/cond-mat/0408187 for the details.

References

A Clauset, MEJ Newman, C Moore: Finding community structure in very large networks, http://www.arxiv.org/abs/cond-mat/0408187

Author

Tamas Nepusz ntamas@gmail.com and Gabor Csardi csardi.gabor@gmail.com for the R interface.

Examples


g <- make_full_graph(5) %du% make_full_graph(5) %du% make_full_graph(5)
g <- add_edges(g, c(1, 6, 1, 11, 6, 11))
fc <- cluster_fast_greedy(g)
membership(fc)
#>  [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2
sizes(fc)
#> Community sizes
#> 1 2 3 
#> 5 5 5