# Create a graph with two nodes
graph <- create_graph(create_nodes(nodes = c("a", "b")))
# Add an edge between those nodes and attach a relationship to the edge
graph <- add_edges(graph, from = "a", to = "b",
rel = "to_get")
# Examples of pipeable graph building using 'create_edges' with
# 'add_edges' in order to include values for the 'style' edge attribute
# (it modifies the style of the connecting line)
library(magrittr)
graph <- create_graph() %>%
add_node("a") %>%
add_node("b") %>%
add_edges(create_edges(from = "a", to = "b",
style = "solid")) %>%
add_node("c") %>%
add_node("d") %>%
add_edges(create_edges(from = "c", to = "d",
style = "dashed")) %>%
add_node("e") %>%
add_node("f") %>%
add_edges(create_edges(from = "e", to = "f",
style = "dotted")) %>%
add_node("g") %>%
add_node("h") %>%
add_edges(create_edges(from = "g", to = "h",
style = "bold"))
Run the code above in your browser using DataLab