library(magrittr)
# Create an empty graph, add a node to it, select
# that node, and then add 5 more nodes to the graph
# with edges from the original node to all of the
# new nodes
graph <-
create_graph() %>%
add_n_nodes(1) %>%
select_last_node %>%
add_n_nodes_ws(5, "from")
# Get the graph's nodes
graph %>% get_nodes
#> [1] "1" "2" "3" "4" "5" "6"
# Get the graph's edges
graph %>% get_edges
#> "1 -> 2" "1 -> 3" "1 -> 4" "1 -> 5" "1 -> 6"
# Create an empty graph, add a node to it, select
# that node, and then add 5 more nodes to the graph
# with edges toward the original node from all of
# the new nodes
graph <-
create_graph() %>%
add_n_nodes(1) %>%
select_last_node %>%
add_n_nodes_ws(5, "to")
# Get the graph's nodes
graph %>% get_nodes
#> [1] "1" "2" "3" "4" "5" "6"
# Get the graph's edges
graph %>% get_edges
#> "2 -> 1" "3 -> 1" "4 -> 1" "5 -> 1" "6 -> 1"
Run the code above in your browser using DataLab