get_successors {DiagrammeR} | R Documentation

## 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

    ## Not run:
    # Before getting node ID values for successors of
    # a specified node, 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),
                   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"))

    # Get sucessors for node "A" in the graph
    get_successors(graph, node = "A")
    #> [1] "Z" "Y"

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

    ## End(Not run)

[Package DiagrammeR version 0.8.2 Index]