EVOLUTION-MANAGER
Edit File: count_triangles.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: Find triangles in graphs</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 count_triangles {igraph}"><tr><td>count_triangles {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Find triangles in graphs</h2> <h3>Description</h3> <p>Count how many triangles a vertex is part of, in a graph, or just list the triangles of a graph. </p> <h3>Usage</h3> <pre> count_triangles(graph, vids = V(graph)) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>graph</code></td> <td> <p>The input graph. It might be directed, but edge directions are ignored.</p> </td></tr> <tr valign="top"><td><code>vids</code></td> <td> <p>The vertices to query, all of them by default. This might be a vector of numeric ids, or a character vector of symbolic vertex names for named graphs.</p> </td></tr> </table> <h3>Details</h3> <p><code>triangles</code> lists all triangles of a graph. For efficiency, all triangles are returned in a single vector. The first three vertices belong to the first triangle, etc. </p> <p><code>count_triangles</code> counts how many triangles a vertex is part of. </p> <h3>Value</h3> <p>For <code>triangles</code> a numeric vector of vertex ids, the first three vertices belong to the first triangle found, etc. </p> <p>For <code>count_triangles</code> a numeric vector, the number of triangles for all vertices queried. </p> <h3>Author(s)</h3> <p>Gabor Csardi <a href="mailto:csardi.gabor@gmail.com">csardi.gabor@gmail.com</a> </p> <h3>See Also</h3> <p><code><a href="transitivity.html">transitivity</a></code> </p> <h3>Examples</h3> <pre> ## A small graph kite <- make_graph("Krackhardt_Kite") plot(kite) matrix(triangles(kite), nrow=3) ## Adjacenct triangles atri <- count_triangles(kite) plot(kite, vertex.label=atri) ## Always true sum(count_triangles(kite)) == length(triangles(kite)) ## Should match, local transitivity is the ## number of adjacent triangles divided by the number ## of adjacency triples transitivity(kite, type="local") count_triangles(kite) / (degree(kite) * (degree(kite)-1)/2) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>