# NOT RUN {
# Create a node data frame (ndf)
ndf <-
create_node_df(
n = 5,
type = c("a", "b", "c", "a", "c"))
# Create an edge data frame (edf)
edf <-
create_edge_df(
from = c(1, 3, 5, 2, 4),
to = c(2, 2, 4, 4, 3),
rel = c("rel_a", "rel_b",
"rel_b", "rel_a",
"rel_c"))
# Create a graph
graph <-
create_graph(
nodes_df = ndf,
edges_df = edf)
# Read the edge `rel` for edge `1`->`2`
graph %>% edge_rel(1, 2)
#> [1] "rel_a"
# Remove the `rel` value entirely from
# edge `1`->`2`
graph <-
graph %>%
edge_rel(
from = 1,
to = 2,
action = "delete")
# Check that the edge `1`->`2` no longer
# has a `rel` assignment
graph %>%
edge_rel(
from = 1,
to = 2,
action = "check")
#> [1] FALSE
# Add the `rel` value `rel_b` to edge `1`->`2`
graph <-
graph %>%
edge_rel(
from = 1,
to = 2,
action = "add",
value = "rel_b")
# Read the edge `rel` for edge `1`->`2`
graph %>%
edge_rel(
from = 1,
to = 2)
#> [1] "rel_b"
# Perform an in-place update of the `rel`
# value for edge `1`->`2` (`rel_b` to `rel_a`)
graph <-
graph %>%
edge_rel(
from = 1,
to = 2,
action = "update",
value = "rel_a")
# Read the edge `rel` for edge `1`->`2`
# to ensure that the change was made
graph %>%
edge_rel(
from = 1,
to = 2)
#> [1] "rel a"
# }
Run the code above in your browser using DataLab