add_edge {DiagrammeR} | R Documentation |
With a graph object of class
dgr_graph
, add an edge to nodes within the
graph.
add_edge(graph, from, to, rel = NULL)
graph |
a graph object of class
|
from |
the outgoing node from which the edge is connected. |
to |
the incoming nodes to which each edge is connected. |
rel |
an optional string specifying the relationship between the connected nodes. |
a graph object of class dgr_graph
.
library(magrittr) # Create a graph with two nodes graph <- create_graph() %>% add_n_nodes(2) # Add an edge between those nodes and attach a # relationship to the edge graph <- add_edge( graph, from = 1, to = 2, rel = "to_get") # Use the `edge_info()` function to verify that # the edge has been created edge_info(graph) #> from to rel #> 1 1 2 to_get