DiagrammeR (version 0.9.0)

get_successors: Get node IDs for successor nodes to the specified node

Description

Provides a vector of node IDs for all nodes that have a connection from the given node.

Usage

get_successors(graph, node)

Arguments

graph

a graph object of class dgr_graph.

node

a node ID for the selected node.

Value

a vector of node ID values.

Examples

Run this code
# NOT RUN {
# Set a seed
set.seed(24)

# Create a node data frame (ndf)
ndf <- create_node_df(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 sucessors for node `4` in the graph
get_successors(graph, node = 4)
#> [1] 2 9

# If there are no successors, NA is returned
get_successors(graph, node = 1)
#> [1] NA
# }

Run the code above in your browser using DataCamp Workspace