EVOLUTION-MANAGER
Edit File: unfold_tree.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: Convert a general graph into a forest</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 unfold_tree {igraph}"><tr><td>unfold_tree {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Convert a general graph into a forest</h2> <h3>Description</h3> <p>Perform a breadth-first search on a graph and convert it into a tree or forest by replicating vertices that were found more than once. </p> <h3>Usage</h3> <pre> unfold_tree(graph, mode = c("all", "out", "in", "total"), roots) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>graph</code></td> <td> <p>The input graph, it can be either directed or undirected.</p> </td></tr> <tr valign="top"><td><code>mode</code></td> <td> <p>Character string, defined the types of the paths used for the breadth-first search. “out” follows the outgoing, “in” the incoming edges, “all” and “total” both of them. This argument is ignored for undirected graphs.</p> </td></tr> <tr valign="top"><td><code>roots</code></td> <td> <p>A vector giving the vertices from which the breadth-first search is performed. Typically it contains one vertex per component.</p> </td></tr> </table> <h3>Details</h3> <p>A forest is a graph, whose components are trees. </p> <p>The <code>roots</code> vector can be calculated by simply doing a topological sort in all components of the graph, see the examples below. </p> <h3>Value</h3> <p>A list with two components: </p> <table summary="R valueblock"> <tr valign="top"><td><code>tree</code></td> <td> <p>The result, an <code>igraph</code> object, a tree or a forest.</p> </td></tr> <tr valign="top"><td><code>vertex_index</code></td> <td> <p>A numeric vector, it gives a mapping from the vertices of the new graph to the vertices of the old graph.</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>Examples</h3> <pre> g <- make_tree(10) %du% make_tree(10) V(g)$id <- seq_len(vcount(g))-1 roots <- sapply(decompose(g), function(x) { V(x)$id[ topo_sort(x)[1]+1 ] }) tree <- unfold_tree(g, roots=roots) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>