add_vertices_raw: Raw/direct interface for adding vertices to graph

View source: R/add_vertices_raw.R

add_vertices_rawR Documentation

Raw/direct interface for adding vertices to graph

Description

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.

Usage

add_vertices_raw(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 with vertices (optional). By default it is assumed that the first column contains the vertex id's (see vertex_id_col).

vertex_id_col

name or number of the column from vertices containing the id's of the vertices. Should contain integer values.

Details

Note that the original graph_id is modified.

Value

Modifies graph_id and returns graph_id.

See Also

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.

Examples

# 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)


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