EVOLUTION-MANAGER
Edit File: diameter.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: Diameter 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 diameter {igraph}"><tr><td>diameter {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Diameter of a graph</h2> <h3>Description</h3> <p>The diameter of a graph is the length of the longest geodesic. </p> <h3>Usage</h3> <pre> diameter(graph, directed = TRUE, unconnected = TRUE, weights = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>graph</code></td> <td> <p>The graph to analyze.</p> </td></tr> <tr valign="top"><td><code>directed</code></td> <td> <p>Logical, whether directed or undirected paths are to be considered. This is ignored for undirected graphs.</p> </td></tr> <tr valign="top"><td><code>unconnected</code></td> <td> <p>Logical, what to do if the graph is unconnected. If FALSE, the function will return a number that is one larger the largest possible diameter, which is always the number of vertices. If TRUE, the diameters of the connected components will be calculated and the largest one will be returned.</p> </td></tr> <tr valign="top"><td><code>weights</code></td> <td> <p>Optional positive weight vector for calculating weighted distances. If the graph has a <code>weight</code> edge attribute, then this is used by default.</p> </td></tr> </table> <h3>Details</h3> <p>The diameter is calculated by using a breadth-first search like method. </p> <p><code>get_diameter</code> returns a path with the actual diameter. If there are many shortest paths of the length of the diameter, then it returns the first one found. </p> <p><code>farthest_vertices</code> returns two vertex ids, the vertices which are connected by the diameter path. </p> <h3>Value</h3> <p>A numeric constant for <code>diameter</code>, a numeric vector for <code>get_diameter</code>. <code>farthest_vertices</code> returns a list with two entries: </p> <ul> <li> <p><code>vertices</code> The two vertices that are the farthest. </p> </li> <li> <p><code>distance</code> Their distance. </p> </li></ul> <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="distances.html">distances</a></code> </p> <h3>Examples</h3> <pre> g <- make_ring(10) g2 <- delete_edges(g, c(1,2,1,10)) diameter(g2, unconnected=TRUE) diameter(g2, unconnected=FALSE) ## Weighted diameter set.seed(1) g <- make_ring(10) E(g)$weight <- sample(seq_len(ecount(g))) diameter(g) get_diameter(g) diameter(g, weights=NA) get_diameter(g, weights=NA) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>