## Not run:
# # Before getting counts of nodes, create a simple graph
# nodes <-
# create_nodes(nodes = LETTERS,
# label = TRUE,
# type = c(rep("a_to_g", 7),
# rep("h_to_p", 9),
# rep("q_to_x", 8),
# rep("y_and_z",2)))
#
# edges <-
# create_edges(from = sample(LETTERS, replace = TRUE),
# to = sample(LETTERS, replace = TRUE),
# rel = "letter_to_letter")
#
# graph <-
# create_graph(nodes_df = nodes,
# edges_df = edges,
# graph_attrs = "layout = neato",
# node_attrs = c("fontname = Helvetica",
# "shape = circle"))
#
# # Get counts of nodes grouped by the "type" attribute
# node_count(graph, type = TRUE) # the default
# #> a_to_g h_to_p q_to_x y_and_z
# #> 7 9 8 2
#
# # Get a total count of nodes with no grouping
# node_count(graph, type = FALSE)
# #> [1] 26
#
# # Get a count of nodes of one or more specified types
# node_count(graph, type = "a_to_g")
# #> [1] 7
#
# node_count(graph, type = c("a_to_g", "q_to_x"))
# #> [1] 15
# ## End(Not run)
Run the code above in your browser using DataLab