# NOT RUN {
# Create a graph with 5 nodes and 4 edges
graph <-
create_graph() %>%
add_path(5) %>%
set_edge_attrs(
"weight", c(3.7, 6.3, 9.2, 1.6))
# We can bucketize values in the edge `weight`
# attribute using `cut_points` and, by doing so,
# assign colors to each of the bucketed ranges
# (for values not part of any bucket, a gray color
# is assigned by default)
graph <-
graph %>%
colorize_edge_attrs(
"weight", "color",
cut_points = c(0, 2, 4, 6, 8, 10))
# Now there will be a `color` edge attribute
# with distinct colors
get_edge_df(graph)
#> id from to rel weight color
#> 1 1 1 2 <NA> 3.7 #FDAE61
#> 2 2 2 3 <NA> 6.3 #ABDDA4
#> 3 3 3 4 <NA> 9.2 #2B83BA
#> 4 4 4 5 <NA> 1.6 #D7191C
# }
Run the code above in your browser using DataLab