add_edges_raw: Raw/direct interface for adding edges to graph

View source: R/add_edges_raw.R

add_edges_rawR Documentation

Raw/direct interface for adding edges to graph

Description

Adds edges to a graph. Assumes that vertices are numbered 0 and up. Does not recode the source and destination id's of the edges. Does not add vertices when these do not yet exists (this will generate an error; edges are added up until the error).

Usage

add_edges_raw(
  graph_id,
  edges,
  edge_src_col = 1,
  edge_dst_col = 2,
  edge_weight_col,
  edge_type_col
)

Arguments

graph_id

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

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 and edge_dst_col).

edge_src_col

name or number of the column from edges containing the source vertex id's of the edges. Column should contain integer values.

edge_dst_col

name or number of the column from edges containing the destination vertex id's of the edges. Column should contain integer values.

edge_weight_col

name or number of the column from edges containing the weights of the edges. When omitted weights of 1 are assumed. Column should contain numeric values.

edge_type_col

name or number of the column from edges containing the types of the edges. When omitted all edges have type 1. Should be of type integer.

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_vertices_raw to create a graph where the user takes care of correctly labelling edges and vertices.

Examples

# Create graph with three vertices and 5 edges between them.
g <- create_graph()
g <- add_vertices_raw(g, data.frame(id = c(0,1,2,3,4)))
g <- add_edges_raw(g, data.frame(src = c(0,0,1,1,2), dst = c(1,2,0,2,0)))
print(g)
delete_graph(g)


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