EVOLUTION-MANAGER
Edit File: modularity.igraph.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: Modularity of a community structure of a graph</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 modularity.igraph {igraph}"><tr><td>modularity.igraph {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Modularity of a community structure of a graph</h2> <h3>Description</h3> <p>This function calculates how modular is a given division of a graph into subgraphs. </p> <h3>Usage</h3> <pre> ## S3 method for class 'igraph' modularity(x, membership, weights = NULL, resolution = 1, directed = TRUE, ...) modularity_matrix( graph, membership, weights = NULL, resolution = 1, directed = TRUE ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, graph</code></td> <td> <p>The input graph.</p> </td></tr> <tr valign="top"><td><code>membership</code></td> <td> <p>Numeric vector, one value for each vertex, the membership vector of the community structure.</p> </td></tr> <tr valign="top"><td><code>weights</code></td> <td> <p>If not <code>NULL</code> then a numeric vector giving edge weights.</p> </td></tr> <tr valign="top"><td><code>resolution</code></td> <td> <p>The resolution parameter. Must be greater than or equal to 0. Set it to 1 to use the classical definition of modularity.</p> </td></tr> <tr valign="top"><td><code>directed</code></td> <td> <p>Whether to use the directed or undirected version of modularity. Ignored for undirected graphs.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments, none currently.</p> </td></tr> </table> <h3>Details</h3> <p><code>modularity</code> calculates the modularity of a graph with respect to the given <code>membership</code> vector. </p> <p>The modularity of a graph with respect to some division (or vertex types) measures how good the division is, or how separated are the different vertex types from each other. It defined as </p> <p style="text-align: center;"><i>Q=1/(2m) * sum( (Aij-gamma*ki*kj/(2m) ) delta(ci,cj),i,j),</i></p> <p> here <i>m</i> is the number of edges, <i>Aij</i> is the element of the <i>A</i> adjacency matrix in row <i>i</i> and column <i>j</i>, <i>ki</i> is the degree of <i>i</i>, <i>kj</i> is the degree of <i>j</i>, <i>ci</i> is the type (or component) of <i>i</i>, <i>cj</i> that of <i>j</i>, the sum goes over all <i>i</i> and <i>j</i> pairs of vertices, and <i>delta(x,y)</i> is 1 if <i>x=y</i> and 0 otherwise. For directed graphs, it is defined as </p> <p style="text-align: center;"><i>Q=1/(m) * sum( (Aij-gamma*ki^out*kj^in/(m) ) delta(ci,cj),i,j).</i></p> <p>The resolution parameter <i>gamma</i> allows weighting the random null model, which might be useful when finding partitions with a high modularity. Maximizing modularity with higher values of the resolution parameter typically results in more, smaller clusters when finding partitions with a high modularity. Lower values typically results in fewer, larger clusters. The original definition of modularity is retrieved when setting <i>gamma</i> to 1. </p> <p>If edge weights are given, then these are considered as the element of the <i>A</i> adjacency matrix, and <i>ki</i> is the sum of weights of adjacent edges for vertex <i>i</i>. </p> <p><code>modularity_matrix</code> calculates the modularity matrix. This is a dense matrix, and it is defined as the difference of the adjacency matrix and the configuration model null model matrix. In other words element <i>M[i,j]</i> is given as <i>A[i,j]-d[i]d[j]/(2m)</i>, where <i>A[i,j]</i> is the (possibly weighted) adjacency matrix, <i>d[i]</i> is the degree of vertex <i>i</i>, and <i>m</i> is the number of edges (or the total weights in the graph, if it is weighed). </p> <h3>Value</h3> <p>For <code>modularity</code> a numeric scalar, the modularity score of the given configuration. </p> <p>For <code>modularity_matrix</code> a numeric square matrix, its order is the number of vertices in the graph. </p> <h3>Author(s)</h3> <p>Gabor Csardi <a href="mailto:csardi.gabor@gmail.com">csardi.gabor@gmail.com</a> </p> <h3>References</h3> <p>Clauset, A.; Newman, M. E. J. & Moore, C. Finding community structure in very large networks, <em>Physical Review E</em> 2004, 70, 066111 </p> <h3>See Also</h3> <p><code><a href="cluster_walktrap.html">cluster_walktrap</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_spinglass.html">cluster_spinglass</a></code>, <code><a href="cluster_louvain.html">cluster_louvain</a></code> and <code><a href="cluster_leiden.html">cluster_leiden</a></code> for various community detection methods. </p> <h3>Examples</h3> <pre> 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)) wtc <- cluster_walktrap(g) modularity(wtc) modularity(g, membership(wtc)) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>