add_edge | 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, edge_aes = NULL, edge_data = NULL)

`graph` |
A graph object of class |

`from` |
The outgoing node from which the edge is connected. There is the
option to use a node |

`to` |
The incoming nodes to which each edge is connected. There is the
option to use a node |

`rel` |
An optional string specifying the relationship between the connected nodes. |

`edge_aes` |
An optional list of named vectors comprising edge aesthetic
attributes. The helper function |

`edge_data` |
An optional list of named vectors comprising edge data
attributes. The helper function |

A graph object of class `dgr_graph`

.

Other Edge creation and removal:
`add_edge_clone()`

,
`add_edge_df()`

,
`add_edges_from_table()`

,
`add_edges_w_string()`

,
`add_forward_edges_ws()`

,
`add_reverse_edges_ws()`

,
`copy_edge_attrs()`

,
`create_edge_df()`

,
`delete_edges_ws()`

,
`delete_edge()`

,
`delete_loop_edges_ws()`

,
`drop_edge_attrs()`

,
`edge_data()`

,
`join_edge_attrs()`

,
`mutate_edge_attrs_ws()`

,
`mutate_edge_attrs()`

,
`recode_edge_attrs()`

,
`rename_edge_attrs()`

,
`rescale_edge_attrs()`

,
`rev_edge_dir_ws()`

,
`rev_edge_dir()`

,
`set_edge_attr_to_display()`

,
`set_edge_attrs_ws()`

,
`set_edge_attrs()`

# Create a graph with 4 nodes graph <- create_graph() %>% add_node(label = "one") %>% add_node(label = "two") %>% add_node(label = "three") %>% add_node(label = "four") # Add an edge between those # nodes and attach a # relationship to the edge graph <- add_edge( graph, from = 1, to = 2, rel = "A") # Use the `get_edge_info()` # function to verify that # the edge has been created graph %>% get_edge_info() # Add another node and # edge to the graph graph <- graph %>% add_edge( from = 3, to = 2, rel = "A") # Verify that the edge # has been created by # counting graph edges graph %>% count_edges() # Add edges by specifying # node `label` values; note # that all nodes must have # unique `label` values to # use this option graph <- graph %>% add_edge( from = "three", to = "four", rel = "L") %>% add_edge( from = "four", to = "one", rel = "L") # Use `get_edges()` to verify # that the edges were added graph %>% get_edges() # Add edge aesthetic and data # attributes during edge creation graph_2 <- create_graph() %>% add_n_nodes(n = 2) %>% add_edge( from = 1, to = 2, rel = "M", edge_aes = edge_aes( penwidth = 1.5, color = "blue"), edge_data = edge_data( value = 4.3)) # Use the `get_edges()` function # to verify that the attribute # values were bound to the # newly created edge graph_2 %>% get_edge_df()

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.