## S3 method for class 'igraph':
+(e1, e2)union.disjoint_union.vertexorverticesfunction, 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 theverticesfunction
specifies the number of vertices to add and their attributes as
well. The unnamed arguments ofverticesare concatenated and
used as thenamevertexis just an alias tovertices, and it is
provided for readability. The user should use it if a single vertex
is added to the graph.
edgeoredgesfunction, then new edges will be added to the
graph. The new edges and possibly their attributes can be specified as
the arguments of theedgesfunction. The unnamed arguments ofedgesare concatenated and used
as vertex ids of the end points of the new edges. The named
arguments will be added as edge attributes.
Examples: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)See more examples below.edgeis just an alias toedgesand it is provided
for readability. The user should use it if a single edge is added to
the graph.
pathfunction, then
new edges that form a path are added. The edges and possibly their
attributes are specified as the arguments to thepathfunction. The non-named arguments are concatenated and interpreted
as the vertex ids along the path. The remaining arguments are added
as edge attributes.Examples: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")
It is important to note that, although the plus operator is commutative, i.e. is possible to write graph <- "foo" + make_empty_graph() it is not associative, e.g. graph <- "foo" + "bar" + make_empty_graph() results a syntax error, unless parentheses are used: graph <- "foo" + ( "bar" + make_empty_graph() ) For clarity, we suggest to always put the graph object on the left hand side of the operator: graph <- make_empty_graph() + "foo" + "bar"
-.igraph,
igraph-minus; add.edges,
add_edges; add.vertices,
add_vertices; delete.edges,
delete_edges;
delete.vertices,
delete_vertices; edge,
edges; path;
vertex, vertices# 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)Run the code above in your browser using DataLab