# NOT RUN {
# Create a random graph
graph <-
create_random_graph(
n = 10, m = 22,
set_seed = 23)
# Get the closeness values for all nodes from `1`
# to `10` and store in the graph's cache
graph <-
graph %>%
set_cache(
name = "closeness_vector",
to_cache = get_closeness(.),
col = "closeness")
# Get the graph's cache
get_cache(
graph,
name = "closeness_vector")
#> [1] 0.07142857 0.07142857 0.07142857 0.06250000
#> [5] 0.07692308 0.09090909 0.06666667 0.05882353
#> [9] 0.07692308 0.07692308
# Get the difference of betweenness and closeness
# values for nodes in the graph and store in the
# graph's cache
graph <-
graph %>%
set_cache(
name = "difference",
to_cache = get_betweenness(.)$betweenness -
get_closeness(.)$closeness)
# Get the graph's cache
get_cache(
graph,
name = "difference")
#> [1] 5.83333333 4.83333333 1.71428571 -0.06250000
#> [5] 5.66117216 20.43290043 3.26666667 -0.05882353
#> [9] 3.66117216 3.99450549
# }
Run the code above in your browser using DataLab