EVOLUTION-MANAGER
Edit File: graph_from_incidence_matrix.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: Create graphs from an incidence matrix</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 graph_from_incidence_matrix {igraph}"><tr><td>graph_from_incidence_matrix {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create graphs from an incidence matrix</h2> <h3>Description</h3> <p><code>graph_from_incidence_matrix</code> creates a bipartite igraph graph from an incidence matrix. </p> <h3>Usage</h3> <pre> graph_from_incidence_matrix( incidence, directed = FALSE, mode = c("all", "out", "in", "total"), multiple = FALSE, weighted = NULL, add.names = NULL ) from_incidence_matrix(...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>incidence</code></td> <td> <p>The input incidence matrix. It can also be a sparse matrix from the <code>Matrix</code> package.</p> </td></tr> <tr valign="top"><td><code>directed</code></td> <td> <p>Logical scalar, whether to create a directed graph.</p> </td></tr> <tr valign="top"><td><code>mode</code></td> <td> <p>A character constant, defines the direction of the edges in directed graphs, ignored for undirected graphs. If ‘<code>out</code>’, then edges go from vertices of the first kind (corresponding to rows in the incidence matrix) to vertices of the second kind (columns in the incidence matrix). If ‘<code>in</code>’, then the opposite direction is used. If ‘<code>all</code>’ or ‘<code>total</code>’, then mutual edges are created.</p> </td></tr> <tr valign="top"><td><code>multiple</code></td> <td> <p>Logical scalar, specifies how to interpret the matrix elements. See details below.</p> </td></tr> <tr valign="top"><td><code>weighted</code></td> <td> <p>This argument specifies whether to create a weighted graph from the incidence matrix. If it is <code>NULL</code> then an unweighted graph is created and the <code>multiple</code> argument is used to determine the edges of the graph. If it is a character constant then for every non-zero matrix entry an edge is created and the value of the entry is added as an edge attribute named by the <code>weighted</code> argument. If it is <code>TRUE</code> then a weighted graph is created and the name of the edge attribute will be ‘<code>weight</code>’.</p> </td></tr> <tr valign="top"><td><code>add.names</code></td> <td> <p>A character constant, <code>NA</code> or <code>NULL</code>. <code>graph_from_incidence_matrix</code> can add the row and column names of the incidence matrix as vertex attributes. If this argument is <code>NULL</code> (the default) and the incidence matrix has both row and column names, then these are added as the ‘<code>name</code>’ vertex attribute. If you want a different vertex attribute for this, then give the name of the attributes as a character string. If this argument is <code>NA</code>, then no vertex attributes (other than type) will be added.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Passed to <code>graph_from_incidence_matrix</code>.</p> </td></tr> </table> <h3>Details</h3> <p>Bipartite graphs have a ‘<code>type</code>’ vertex attribute in igraph, this is boolean and <code>FALSE</code> for the vertices of the first kind and <code>TRUE</code> for vertices of the second kind. </p> <p><code>graph_from_incidence_matrix</code> can operate in two modes, depending on the <code>multiple</code> argument. If it is <code>FALSE</code> then a single edge is created for every non-zero element in the incidence matrix. If <code>multiple</code> is <code>TRUE</code>, then the matrix elements are rounded up to the closest non-negative integer to get the number of edges to create between a pair of vertices. </p> <h3>Value</h3> <p>A bipartite igraph graph. In other words, an igraph graph that has a vertex attribute <code>type</code>. </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="make_bipartite_graph.html">make_bipartite_graph</a></code> for another way to create bipartite graphs </p> <h3>Examples</h3> <pre> inc <- matrix(sample(0:1, 15, repl=TRUE), 3, 5) colnames(inc) <- letters[1:5] rownames(inc) <- LETTERS[1:3] graph_from_incidence_matrix(inc) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>