add_vertices: Add vertices to graph

View source: R/add_vertices.R

add_verticesR Documentation

Add vertices to graph

Description

Add vertices to graph

Usage

add_vertices(graph_id, vertices, vertex_id_col = 1L)

Arguments

graph_id

the graph to which to add the edges and vertices. Should be of type chickenwire.

vertices

a data.frame or vector with vertices. By default it is assumed that the first column of the data.frame contains the vertex id's (see vertex_id_col). This column, or the vector supplied should of type numeric, character or factor.

vertex_id_col

name or number of the column from vertices containing the id's of the vertices. Used when a data.frame is supplied for vertices.

Details

Note that the original graph_id is modified.

Value

Modifies graph_id and returns graph_id.

Examples

# Create a graph with 4 vertices without edges
g <- create_graph()
g <- add_vertices(g, data.frame(id = c(1,2,3,4)))
print(g)
delete_graph(g)



djvanderlaan/chickenwire-r documentation built on July 19, 2022, 1:16 a.m.