Learn R Programming

DiagrammeR (version 0.8.2)

node_info: Get detailed information on nodes

Description

Obtain a data frame with detailed information on nodes and their interrelationships within a graph.

Usage

node_info(graph)

Arguments

graph
a graph object of class dgr_graph.

Value

a data frame containing information specific to each node within the graph.

Examples

Run this code
## Not run: 
# # Create a simple graph and get node information from it
# 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),
#                label = "edge",
#                rel = "letter_to_letter")
# 
# graph <-
#   create_graph(nodes_df = nodes,
#                edges_df = edges,
#                graph_attrs = "layout = neato",
#                node_attrs = c("fontname = Helvetica",
#                               "shape = circle"))
# 
# node_info(graph)
# #>    node label    type degree indegree outdegree loops
# #> 1     A     A  a_to_g      2        0         2     0
# #> 2     W     W  q_to_x      1        0         1     0
# #> 3     T     T  q_to_x      2        0         2     0
# #> 4     L     L  h_to_p      1        0         1     0
# #> 5     F     F  a_to_g      0        0         0     0
# #>..   ...   ...     ...    ...      ...       ...   ...
# 
# # Import a large graph
# power_grid <-
# import_graph(system.file("examples/power_grid.graphml",
#                          package = "DiagrammeR"))
# 
# # Use dplyr::filter to determine which nodes are highly
# # connected in this graph
# library(dplyr)
# 
# high_connect_nodes <-
#   filter(node_info(power_grid), degree > 10)$node
# ## End(Not run)

Run the code above in your browser using DataLab