EVOLUTION-MANAGER
Edit File: diversity.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: Graph diversity</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 diversity {igraph}"><tr><td>diversity {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Graph diversity</h2> <h3>Description</h3> <p>Calculates a measure of diversity for all vertices. </p> <h3>Usage</h3> <pre> diversity(graph, weights = NULL, vids = V(graph)) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>graph</code></td> <td> <p>The input graph. Edge directions are ignored.</p> </td></tr> <tr valign="top"><td><code>weights</code></td> <td> <p><code>NULL</code>, or the vector of edge weights to use for the computation. If <code>NULL</code>, then the ‘weight’ attibute is used. Note that this measure is not defined for unweighted graphs.</p> </td></tr> <tr valign="top"><td><code>vids</code></td> <td> <p>The vertex ids for which to calculate the measure.</p> </td></tr> </table> <h3>Details</h3> <p>The diversity of a vertex is defined as the (scaled) Shannon entropy of the weights of its incident edges: </p> <p style="text-align: center;"><i>D(i)=H(i)/log(k[i])</i></p> <p>and </p> <p style="text-align: center;"><i>H(i) = -sum(p[i,j] log(p[i,j]), j=1..k[i]),</i></p> <p> where </p> <p style="text-align: center;"><i>p[i,j] = w[i,j] / sum(w[i,l], l=1..k[i]),</i></p> <p> and <i>k[i]</i> is the (total) degree of vertex <i>i</i>, <i>w[i,j]</i> is the weight of the edge(s) between vertices <i>i</i> and <i>j</i>. </p> <p>For vertices with degree less than two the function returns <code>NaN</code>. </p> <h3>Value</h3> <p>A numeric vector, its length is the number of vertices. </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>Nathan Eagle, Michael Macy and Rob Claxton: Network Diversity and Economic Development, <em>Science</em> <b>328</b>, 1029–1031, 2010. </p> <h3>Examples</h3> <pre> g1 <- sample_gnp(20, 2/20) g2 <- sample_gnp(20, 2/20) g3 <- sample_gnp(20, 5/20) E(g1)$weight <- 1 E(g2)$weight <- runif(ecount(g2)) E(g3)$weight <- runif(ecount(g3)) diversity(g1) diversity(g2) diversity(g3) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>