Finds the optimal community structure by maximizing modularity exactly. Very slow - only use for small networks (<50 nodes).
Arguments
- x
Network input
- weights
Edge weights. NULL uses network weights, NA for unweighted.
- ...
Additional arguments passed to
to_igraph
References
Brandes, U., Delling, D., Gaertler, M., Gorke, R., Hoefer, M., Nikoloski, Z., & Wagner, D. (2008). On modularity clustering. IEEE Transactions on Knowledge and Data Engineering, 20(2), 172-188.
Examples
g <- igraph::make_ring(10)
comm <- community_optimal(g)
igraph::membership(comm)
#> [1] 1 1 2 2 2 3 3 3 3 1
net <- as_cograph(matrix(runif(25), 5, 5))
com_op(net)
#> Community structure (optimal)
#> Number of communities: 2
#> Modularity: 0.2432
#> Community sizes: 4, 1
#> Nodes: 5
