Add edges from an edge data frame to an existing graph object
Source:R/add_edge_df.R
add_edge_df.Rd
With a graph object of class dgr_graph
, add edges from an edge data frame
to that graph.
Arguments
- graph
A graph object of class
dgr_graph
.- edge_df
An edge data frame that is created using
create_edge_df()
.
See also
Other edge creation and removal:
add_edge()
,
add_edge_clone()
,
add_edges_from_table()
,
add_edges_w_string()
,
add_forward_edges_ws()
,
add_reverse_edges_ws()
,
copy_edge_attrs()
,
create_edge_df()
,
delete_edge()
,
delete_edges_ws()
,
delete_loop_edges_ws()
,
drop_edge_attrs()
,
edge_data()
,
join_edge_attrs()
,
mutate_edge_attrs()
,
mutate_edge_attrs_ws()
,
recode_edge_attrs()
,
rename_edge_attrs()
,
rescale_edge_attrs()
,
rev_edge_dir()
,
rev_edge_dir_ws()
,
set_edge_attr_to_display()
,
set_edge_attrs()
,
set_edge_attrs_ws()
Examples
# Create a graph with 4 nodes
# and no edges
graph <-
create_graph() %>%
add_n_nodes(n = 4)
# Create an edge data frame (edf)
edf <-
create_edge_df(
from = c(1, 2, 3),
to = c(4, 3, 1))
# Add the edge data frame to
# the graph object to create
# a graph with both nodes
# and edges
graph <-
graph %>%
add_edge_df(
edge_df = edf)
# Get the graph's edges to
# verify that the edf had
# been added
graph %>%
get_edges(
return_type = "vector")
#> [1] "1->4" "2->3" "3->1"