Description Usage Arguments Details Value Examples Author(s) References See Also

This function calculates the optimal community structure of a graph, by maximizing the modularity measure over all possible partitions.

1 |

`graph` |
The input graph. Edge directions are ignored for directed graphs. |

`weights` |
Optional positive weight vector for optimizing weighted
modularity. If the graph has a |

This function calculates the optimal community structure for a graph, in terms of maximal modularity score.

The calculation is done by transforming the modularity maximization into an integer programming problem, and then calling the GLPK library to solve that. Please the reference below for details.

Note that modularity optimization is an NP-complete problem, and all known algorithms for it have exponential time complexity. This means that you probably don't want to run this function on larger graphs. Graphs with up to fifty vertices should be fine, graphs with a couple of hundred vertices might be possible.

`cluster_optimal`

returns a `communities`

object,
please see the `communities`

manual page for details.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ```
## Zachary's karate club
g <- make_graph("Zachary")
## We put everything into a big 'try' block, in case
## igraph was compiled without GLPK support
## The calculation only takes a couple of seconds
oc <- cluster_optimal(g)
## Double check the result
print(modularity(oc))
print(modularity(g, membership(oc)))
## Compare to the greedy optimizer
fc <- cluster_fast_greedy(g)
print(modularity(fc))
``` |

Gabor Csardi csardi.gabor@gmail.com

Ulrik Brandes, Daniel Delling, Marco Gaertler, Robert Gorke,
Martin Hoefer, Zoran Nikoloski, Dorothea Wagner: On Modularity Clustering,
*IEEE Transactions on Knowledge and Data Engineering* 20(2):172-188,
2008.

`communities`

for the documentation of the result,
`modularity`

. See also `cluster_fast_greedy`

for a
fast greedy optimizer.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.