DiagrammeR (version 0.9.0)

cache_node_count_ws: Cache a count of nodes (available in a selection) in the graph

Description

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_node(), 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().

Usage

cache_node_count_ws(graph)

Arguments

graph

a graph object of class dgr_graph.

Value

a graph object of class dgr_graph.

Examples

Run this code
# NOT RUN {
# Create a graph with 5 nodes and 4 edges
graph <-
  create_graph() %>%
  add_path(5)

# Cache a count of nodes after creating a selection
graph <-
  graph %>%
  select_nodes_by_id(2:5) %>%
  cache_node_count_ws()

# Get the number of nodes stored in the cache
graph %>% get_cache()
#> [1] 4
# }

Run the code above in your browser using DataCamp Workspace