Add one or more edges using a text string
With a graph object of class dgr_graph
, add one or more edges to the graph
using a text string.
add_edges_w_string(graph, edges, rel = NULL, use_labels = FALSE)
graph |
A graph object of class |
edges |
A single-length vector with a character string specifying the
edges. For a directed graph, the string object should be formatted as a
series of node ID values as |
rel |
An optional vector specifying the relationship between the connected nodes. |
use_labels |
An option to use node |
A graph object of class dgr_graph
.
Other Edge creation and removal:
add_edge_clone()
,
add_edge_df()
,
add_edges_from_table()
,
add_edge()
,
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 edges between nodes using # a character string with node # ID values graph_node_id <- graph %>% add_edges_w_string( edges = "1->2 1->3 2->4 2->3") # Show the graph's internal # edge data frame graph_node_id %>% get_edge_df() # Add edges between nodes using # a character string with node # label values and setting # `use_labels = TRUE`; note that # all nodes must have unique # `label` values to use this graph_node_label <- graph %>% add_edges_w_string( edges = "one->two one->three two->four two->three", use_labels = TRUE) # Show the graph's internal # edge data frame (it's the # same as before) graph_node_label %>% get_edge_df()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.