EVOLUTION-MANAGER
Edit File: cluster_leiden.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Finding community structure of a graph using the Leiden...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for cluster_leiden {igraph}"><tr><td>cluster_leiden {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Finding community structure of a graph using the Leiden algorithm of Traag, van Eck & Waltman.</h2> <h3>Description</h3> <p>The Leiden algorithm is similar to the Louvain algorithm, <code><a href="cluster_louvain.html">cluster_louvain</a></code>, but it is faster and yields higher quality solutions. It can optimize both modularity and the Constant Potts Model, which does not suffer from the resolution-limit (see preprint http://arxiv.org/abs/1104.3083). </p> <h3>Usage</h3> <pre> cluster_leiden( graph, objective_function = c("CPM", "modularity"), weights = NULL, resolution_parameter = 1, beta = 0.01, initial_membership = NULL, n_iterations = 2, vertex_weights = NULL ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>graph</code></td> <td> <p>The input graph, only undirected graphs are supported.</p> </td></tr> <tr valign="top"><td><code>objective_function</code></td> <td> <p>Whether to use the Constant Potts Model (CPM) or modularity. Must be either <code>"CPM"</code> or <code>"modularity"</code>.</p> </td></tr> <tr valign="top"><td><code>weights</code></td> <td> <p>The weights of the edges. It must be a positive numeric vector, <code>NULL</code> or <code>NA</code>. If it is <code>NULL</code> and the input graph has a ‘weight’ edge attribute, then that attribute will be used. If <code>NULL</code> and no such attribute is present, then the edges will have equal weights. Set this to <code>NA</code> 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.</p> </td></tr> <tr valign="top"><td><code>resolution_parameter</code></td> <td> <p>The resolution parameter to use. Higher resolutions lead to more smaller communities, while lower resolutions lead to fewer larger communities.</p> </td></tr> <tr valign="top"><td><code>beta</code></td> <td> <p>Parameter affecting the randomness in the Leiden algorithm. This affects only the refinement step of the algorithm.</p> </td></tr> <tr valign="top"><td><code>initial_membership</code></td> <td> <p>If provided, the Leiden algorithm will try to improve this provided membership. If no argument is provided, the aglorithm simply starts from the singleton partition.</p> </td></tr> <tr valign="top"><td><code>n_iterations</code></td> <td> <p>the number of iterations to iterate the Leiden algorithm. Each iteration may improve the partition further.</p> </td></tr> <tr valign="top"><td><code>vertex_weights</code></td> <td> <p>the vertex weights used in the Leiden algorithm. If this is not provided, it will be automatically determined on the basis of the <code>objective_function</code>. Please see the details of this function how to interpret the vertex weights.</p> </td></tr> </table> <h3>Details</h3> <p>The Leiden algorithm consists of three phases: (1) local moving of nodes, (2) refinement of the partition and (3) aggregation of the network based on the refined partition, using the non-refined partition to create an initial partition for the aggregate network. In the local move procedure in the Leiden algorithm, only nodes whose neighborhood has changed are visited. The refinement is done by restarting from a singleton partition within each cluster and gradually merging the subclusters. When aggregating, a single cluster may then be represented by several nodes (which are the subclusters identified in the refinement). </p> <p>The Leiden algorithm provides several guarantees. The Leiden algorithm is typically iterated: the output of one iteration is used as the input for the next iteration. At each iteration all clusters are guaranteed to be connected and well-separated. After an iteration in which nothing has changed, all nodes and some parts are guaranteed to be locally optimally assigned. Finally, asymptotically, all subsets of all clusters are guaranteed to be locally optimally assigned. For more details, please see Traag, Waltman & van Eck (2019). </p> <p>The objective function being optimized is </p> <p style="text-align: center;"><i>1 / 2m sum_ij (A_ij - gamma n_i n_j)d(s_i, s_j)</i></p> <p>where <i>m</i> is the total edge weight, <i>A_ij</i> is the weight of edge <i>(i, j)</i>, <i>gamma</i> is the so-called resolution parameter, <i>n_i</i> is the node weight of node <i>i</i>, <i>s_i</i> is the cluster of node <i>i</i> and <i>d(x, y) = 1</i> if and only if <i>x = y</i> and <i>0</i> otherwise. By setting <i>n_i = k_i</i>, the degree of node <i>i</i>, and dividing <i>gamma</i> by <i>2m</i>, you effectively obtain an expression for modularity. </p> <p>Hence, the standard modularity will be optimized when you supply the degrees as <code>vertex_weights</code> and by supplying as a resolution parameter <i>1/(2m)</i>, with <i>m</i> the number of edges. If you do not specify any <code>vertex_weights</code>, the correct vertex weights and scaling of <i>gamma</i> is determined automatically by the <code>objective_function</code> argument. </p> <h3>Value</h3> <p><code>cluster_leiden</code> returns a <code><a href="communities.html">communities</a></code> object, please see the <code><a href="communities.html">communities</a></code> manual page for details. </p> <h3>Author(s)</h3> <p>Vincent Traag </p> <h3>References</h3> <p>Traag, V. A., Waltman, L., & van Eck, N. J. (2019). From Louvain to Leiden: guaranteeing well-connected communities. Scientific reports, 9(1), 5233. doi: 10.1038/s41598-019-41695-z, arXiv:1810.08473v3 [cs.SI] </p> <h3>See Also</h3> <p>See <code><a href="communities.html">communities</a></code> for extracting the membership, modularity scores, etc. from the results. </p> <p>Other community detection algorithms: <code><a href="cluster_walktrap.html">cluster_walktrap</a></code>, <code><a href="cluster_spinglass.html">cluster_spinglass</a></code>, <code><a href="cluster_leading_eigen.html">cluster_leading_eigen</a></code>, <code><a href="cluster_edge_betweenness.html">cluster_edge_betweenness</a></code>, <code><a href="cluster_fast_greedy.html">cluster_fast_greedy</a></code>, <code><a href="cluster_label_prop.html">cluster_label_prop</a></code> <code><a href="cluster_louvain.html">cluster_louvain</a></code> <code><a href="cluster_fluid_communities.html">cluster_fluid_communities</a></code> <code><a href="cluster_infomap.html">cluster_infomap</a></code> <code><a href="cluster_optimal.html">cluster_optimal</a></code> <code><a href="cluster_walktrap.html">cluster_walktrap</a></code> </p> <h3>Examples</h3> <pre> g <- make_graph("Zachary") # By default CPM is used r <- quantile(strength(g))[2] / (gorder(g) - 1) # Set seed for sake of reproducibility set.seed(1) ldc <- cluster_leiden(g, resolution_parameter=r) print(ldc) plot(ldc, g) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>