get_predecessors {DiagrammeR} | R Documentation |
Provides a vector of node IDs for all nodes that have a connection to the given node.
get_predecessors(graph, node)
graph |
a graph object of class
|
node |
a node ID for the selected node. |
a vector of node ID values.
# Set a seed set.seed(23) # Create a node data frame (ndf) ndf <- create_node_df(n = 26) # Create an edge data frame (edf) edf <- create_edge_df( from = sample(1:26, replace = TRUE), to = sample(1:26, replace = TRUE)) # From the ndf and edf, create a graph object graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get predecessors for node `23` in the graph get_predecessors(graph, node = 23) #> [1] 6 # If there are no predecessors, `NA` is returned get_predecessors(graph, node = 26) #> [1] NA