View source: R/add_vertices_raw.R
add_vertices_raw | R Documentation |
Add vertices to graph. Assumes vertices are numbered 0 and up. To use the raw interface the user should ensure that the vertices (and edges) are labelled using sequential integers starting from 0.
add_vertices_raw(graph_id, vertices, vertex_id_col = 1L)
graph_id |
the graph to which to add the edges and vertices. Should
be of type |
vertices |
a data.frame with vertices (optional). By default it is assumed that
the first column contains the vertex id's (see |
vertex_id_col |
name or number of the column from |
Note that the original graph_id
is modified.
Modifies graph_id
and returns graph_id
.
Is intended to be used together with add_edges_raw
to create a
graph where the user takes care of correctly labelling edges and vertices.
# Create a graph with 4 vertices without edges g <- create_graph() g <- add_vertices_raw(g, data.frame(id = c(0,1,2,3))) print(g) delete_graph(g) # The example below shows what happens when vertices are not numbered # sequentially from 0. Althoug we only add 4 vertices, the graph contains # 5 vertices. This is because the vertex labelled 0 is automatically added # when adding vertex 1. g <- create_graph() g <- add_vertices_raw(g, data.frame(id = c(1,2,3,4))) print(g) delete_graph(g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.