EVOLUTION-MANAGER
Edit File: knn.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: Average nearest neighbor degree</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 knn {igraph}"><tr><td>knn {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Average nearest neighbor degree</h2> <h3>Description</h3> <p>Calculate the average nearest neighbor degree of the given vertices and the same quantity in the function of vertex degree </p> <h3>Usage</h3> <pre> knn( graph, vids = V(graph), mode = c("all", "out", "in", "total"), neighbor.degree.mode = c("all", "out", "in", "total"), weights = NULL ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>graph</code></td> <td> <p>The input graph. It may be directed.</p> </td></tr> <tr valign="top"><td><code>vids</code></td> <td> <p>The vertices for which the calculation is performed. Normally it includes all vertices. Note, that if not all vertices are given here, then both ‘<code>knn</code>’ and ‘<code>knnk</code>’ will be calculated based on the given vertices only.</p> </td></tr> <tr valign="top"><td><code>mode</code></td> <td> <p>Character constant to indicate the type of neighbors to consider in directed graphs. <code>out</code> considers out-neighbors, <code>in</code> considers in-neighbors and <code>all</code> ignores edge directions.</p> </td></tr> <tr valign="top"><td><code>neighbor.degree.mode</code></td> <td> <p>The type of degree to average in directed graphs. <code>out</code> averages out-degrees, <code>in</code> averages in-degrees and <code>all</code> ignores edge directions for the degree calculation.</p> </td></tr> <tr valign="top"><td><code>weights</code></td> <td> <p>Weight vector. If the graph has a <code>weight</code> edge attribute, then this is used by default. If this argument is given, then vertex strength (see <code><a href="strength.html">strength</a></code>) is used instead of vertex degree. But note that <code>knnk</code> is still given in the function of the normal vertex degree. Weights are are used to calculate a weighted degree (also called <code><a href="strength.html">strength</a></code>) instead of the degree.</p> </td></tr> </table> <h3>Details</h3> <p>Note that for zero degree vertices the answer in ‘<code>knn</code>’ is <code>NaN</code> (zero divided by zero), the same is true for ‘<code>knnk</code>’ if a given degree never appears in the network. </p> <p>The weighted version computes a weighted average of the neighbor degrees as </p> <p><code>k_nn_u = 1/s_u sum_v w_uv k_v</code>, </p> <p>where <code>s_u = sum_v w_uv</code> is the sum of the incident edge weights of vertex <code>u</code>, i.e. its strength. The sum runs over the neighbors <code>v</code> of vertex <code>u</code> as indicated by <code>mode</code>. <code>w_uv</code> denotes the weighted adjacency matrix and <code>k_v</code> is the neighbors' degree, specified by <code>neighbor_degree_mode</code>. </p> <h3>Value</h3> <p>A list with two members: </p> <table summary="R valueblock"> <tr valign="top"><td><code>knn</code></td> <td> <p>A numeric vector giving the average nearest neighbor degree for all vertices in <code>vids</code>.</p> </td></tr> <tr valign="top"><td><code>knnk</code></td> <td> <p>A numeric vector, its length is the maximum (total) vertex degree in the graph. The first element is the average nearest neighbor degree of vertices with degree one, etc. </p> </td></tr> </table> <h3>Author(s)</h3> <p>Gabor Csardi <a href="mailto:csardi.gabor@gmail.com">csardi.gabor@gmail.com</a> </p> <h3>References</h3> <p>Alain Barrat, Marc Barthelemy, Romualdo Pastor-Satorras, Alessandro Vespignani: The architecture of complex weighted networks, Proc. Natl. Acad. Sci. USA 101, 3747 (2004) </p> <h3>Examples</h3> <pre> # Some trivial ones g <- make_ring(10) knn(g) g2 <- make_star(10) knn(g2) # A scale-free one, try to plot 'knnk' g3 <- sample_pa(1000, m=5) knn(g3) # A random graph g4 <- sample_gnp(1000, p=5/1000) knn(g4) # A weighted graph g5 <- make_star(10) E(g5)$weight <- seq(ecount(g5)) knn(g5) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>