From a graph object of class
dgr_graph, get a count of nodes available in
a selection and cache that value in the graph for
later retrieval using get_cache.
Selections of nodes can be performed using
the following select_... functions:
select_nodes(),
select_last_nodes_created(),
select_nodes_by_degree(),
select_nodes_by_id(), or
select_nodes_in_neighborhood().
Selections of nodes can also be performed using
the following traversal functions:
(trav_...):
trav_out(), trav_in(),
trav_both(), trav_in_node(),
trav_out_node().
cache_node_count_ws(graph, name = NULL)
| graph | a graph object of class
|
|---|---|
| name | an optional name for the cached vector. |
a graph object of class dgr_graph.
# NOT RUN { # Create a graph with 5 nodes and 4 edges graph <- create_graph() %>% add_path(n = 5) # Cache a count of nodes after creating a selection graph <- graph %>% select_nodes_by_id(nodes = 2:5) %>% cache_node_count_ws(name = "node_count") # Get the number of nodes stored in the cache graph %>% get_cache(name = "node_count") #> [1] 4 # }