add_edges_w_string {DiagrammeR} | R Documentation |
With a graph object of class
dgr_graph
, add one or more edges to the graph
using a text string. For a directed graph, the
string object should be formatted as a series of
node ID values as [node_ID_1]->[node_ID_2]
separated by a single space. For undirected graphs,
--
should replace ->
.
add_edges_w_string(graph, edges, rel = NULL)
graph |
a graph object of class
|
edges |
a single-length vector with a character string specifying the edges. |
rel |
an optional vector specifying the relationship between the connected nodes. |
a graph object of class dgr_graph
.
library(magrittr) # Create a graph with 10 nodes graph <- create_graph() %>% add_n_nodes(10) # Add edges between nodes using a character string graph <- graph %>% add_edges_w_string( "1->2 1->3 2->4 2->5 3->6 3->7 4->8 4->9 5->10")