Learn R Programming

DiagrammeR (version 0.7)

add_edges: Add edges to an existing graph object

Description

With a graph object of class dgr_graph, add one or more edges of specified types to nodes within the graph.

Usage

add_edges(graph, edges_df = NULL, from = NULL, to = NULL,
  relationship = NULL)

Arguments

graph
a graph object of class dgr_graph that is created using create_graph.
edges_df
an edge data frame that is created using create_edges.
from
a vector of the outgoing nodes from which each edge is connected.
to
a vector of the incoming nodes to which each edge is connected.
relationship
a string specifying the relationship between the connected nodes.

Value

  • a graph object of class dgr_graph.

Examples

Run this code
# Create a graph with two nodes
graph <- create_graph(create_nodes(nodes = c("a", "b")))

# Add an edge between those nodes and attach a relationship
graph <- add_edges(graph, from = "a", to = "b",
                   relationship = "to_get")

Run the code above in your browser using DataLab