# NOT RUN {
# Create a simple graph
graph <-
create_graph() %>%
add_path(n = 6)
# Select specific nodes from the graph and
# apply the node attribute `color = blue` to
# those selected nodes
graph <-
graph %>%
select_nodes_by_id(
nodes = 1:4) %>%
trav_out() %>%
set_node_attrs_ws(
node_attr = color,
value = "blue")
# Show the internal node data frame to verify
# that the node attribute has been set for
# specific node
get_node_df(graph)
#> id type label color
#> 1 1 <NA> 1 <NA>
#> 2 2 <NA> 2 blue
#> 3 3 <NA> 3 blue
#> 4 4 <NA> 4 blue
#> 5 5 <NA> 5 blue
#> 6 6 <NA> 6 <NA>
# }
Run the code above in your browser using DataLab