add_edges | R Documentation |
Add edges to graph
add_edges( graph_id, edges, edge_src_col = 1, edge_dst_col = 2, edge_weight_col, edge_type_col, auto_add_vertices = TRUE )
graph_id |
the graph to which to add the edges and vertices. Should
be of type |
edges |
a data.frame withe edges. Should contain at least two columns:
source vertex id's of the edge and destination id's. By default it is assumed
that these are in the first two columns of the data.frame (see |
edge_src_col |
name or number of the column from |
edge_dst_col |
name or number of the column from |
edge_weight_col |
name or number of the column from |
edge_type_col |
name or number of the column from |
auto_add_vertices |
automatically create vertices when an edge contains id's that
do not exist yet. When |
Note that the original graph_id
is modified.
Modifies graph_id
and returns graph_id
.
# Create graph with three vertices and 5 edges between them. g <- create_graph() g <- add_edges(g, data.frame(src = c(1,1,2,2,3), dst = c(2,3,1,3,1))) print(g) delete_graph(g) # Create graph with four vertices and 5 edges between them; one of the # vertices does not have edges. g <- create_graph() g <- add_vertices(g, 1:4) g <- add_edges(g, data.frame(src = c(1,1,2,2,3), dst = c(2,3,1,3,1))) print(g) delete_graph(g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.