EVOLUTION-MANAGER
Edit File: plus-.igraph.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: Add vertices, edges or another graph to 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 +.igraph {igraph}"><tr><td>+.igraph {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add vertices, edges or another graph to a graph</h2> <h3>Description</h3> <p>Add vertices, edges or another graph to a graph </p> <h3>Usage</h3> <pre> ## S3 method for class 'igraph' e1 + e2 </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>e1</code></td> <td> <p>First argument, probably an igraph graph, but see details below.</p> </td></tr> <tr valign="top"><td><code>e2</code></td> <td> <p>Second argument, see details below.</p> </td></tr> </table> <h3>Details</h3> <p>The plus operator can be used to add vertices or edges to graph. The actual operation that is performed depends on the type of the right hand side argument. </p> <ul> <li><p> If is is another igraph graph object and they are both named graphs, then the union of the two graphs are calculated, see <code><a href="union.html">union</a></code>. </p> </li> <li><p> If it is another igraph graph object, but either of the two are not named, then the disjoint union of the two graphs is calculated, see <code><a href="disjoint_union.html">disjoint_union</a></code>. </p> </li> <li><p> If it is a numeric scalar, then the specified number of vertices are added to the graph. </p> </li> <li><p> If it is a character scalar or vector, then it is interpreted as the names of the vertices to add to the graph. </p> </li> <li><p> If it is an object created with the <code><a href="vertex.html">vertex</a></code> or <code><a href="vertex.html">vertices</a></code> function, then new vertices are added to the graph. This form is appropriate when one wants to add some vertex attributes as well. The operands of the <code>vertices</code> function specifies the number of vertices to add and their attributes as well. </p> <p>The unnamed arguments of <code>vertices</code> are concatenated and used as the ‘<code>name</code>’ vertex attribute (i.e. vertex names), the named arguments will be added as additional vertex attributes. Examples: </p> <pre> g <- g + vertex(shape="circle", color= "red") g <- g + vertex("foo", color="blue") g <- g + vertex("bar", "foobar") g <- g + vertices("bar2", "foobar2", color=1:2, shape="rectangle")</pre> <p><code>vertex</code> is just an alias to <code>vertices</code>, and it is provided for readability. The user should use it if a single vertex is added to the graph. </p> </li> <li><p> If it is an object created with the <code><a href="edge.html">edge</a></code> or <code><a href="edge.html">edges</a></code> function, then new edges will be added to the graph. The new edges and possibly their attributes can be specified as the arguments of the <code>edges</code> function. </p> <p>The unnamed arguments of <code>edges</code> are concatenated and used as vertex ids of the end points of the new edges. The named arguments will be added as edge attributes. </p> <p>Examples: </p> <pre> g <- make_empty_graph() + vertices(letters[1:10]) + vertices("foo", "bar", "bar2", "foobar2") g <- g + edge("a", "b") g <- g + edges("foo", "bar", "bar2", "foobar2") g <- g + edges(c("bar", "foo", "foobar2", "bar2"), color="red", weight=1:2)</pre> <p>See more examples below. </p> <p><code>edge</code> is just an alias to <code>edges</code> and it is provided for readability. The user should use it if a single edge is added to the graph. </p> </li> <li><p> If it is an object created with the <code><a href="path.html">path</a></code> function, then new edges that form a path are added. The edges and possibly their attributes are specified as the arguments to the <code>path</code> function. The non-named arguments are concatenated and interpreted as the vertex ids along the path. The remaining arguments are added as edge attributes. </p> <p>Examples: </p> <pre> g <- make_empty_graph() + vertices(letters[1:10]) g <- g + path("a", "b", "c", "d") g <- g + path("e", "f", "g", weight=1:2, color="red") g <- g + path(c("f", "c", "j", "d"), width=1:3, color="green")</pre> </li></ul> <p>It is important to note that, although the plus operator is commutative, i.e. is possible to write </p> <pre> graph <- "foo" + make_empty_graph()</pre> <p>it is not associative, e.g. </p> <pre> graph <- "foo" + "bar" + make_empty_graph()</pre> <p>results a syntax error, unless parentheses are used: </p> <pre> graph <- "foo" + ( "bar" + make_empty_graph() )</pre> <p>For clarity, we suggest to always put the graph object on the left hand side of the operator: </p> <pre> graph <- make_empty_graph() + "foo" + "bar"</pre> <h3>See Also</h3> <p>Other functions for manipulating graph structure: <code><a href="add_edges.html">add_edges</a>()</code>, <code><a href="add_vertices.html">add_vertices</a>()</code>, <code><a href="delete_edges.html">delete_edges</a>()</code>, <code><a href="delete_vertices.html">delete_vertices</a>()</code>, <code><a href="edge.html">edge</a>()</code>, <code><a href="igraph-minus.html">igraph-minus</a></code>, <code><a href="path.html">path</a>()</code>, <code><a href="vertex.html">vertex</a>()</code> </p> <h3>Examples</h3> <pre> # 10 vertices named a,b,c,... and no edges g <- make_empty_graph() + vertices(letters[1:10]) # Add edges to make it a ring g <- g + path(letters[1:10], letters[1], color = "grey") # Add some extra random edges g <- g + edges(sample(V(g), 10, replace = TRUE), color = "red") g$layout <- layout_in_circle plot(g) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>