trav_in_node {DiagrammeR} | R Documentation |
From a graph object of class
dgr_graph
move to adjacent nodes from a
selection of one or more selected edges where the
edges are inward edges to those nodes. This creates
a selection of nodes. An optional filter by node
attribute can limit the set of nodes traversed to.
trav_in_node(graph, node_attr = NULL, match = NULL)
graph |
a graph object of class
|
node_attr |
an optional character vector of node attribute values for filtering the node ID values returned. |
match |
an option to provide a logical
expression with a comparison operator ( |
a graph object of class dgr_graph
.
library(magrittr) # Create a simple graph graph <- create_graph() %>% add_n_nodes(2) %>% add_edge(1, 2) # Traverse from nodes `1` to to `2` by: # (1) moving from node `1` to edge `1` -> `2` # (2) moving from edge `1` -> `2` to node `2` graph <- graph %>% select_nodes_by_id(1) %>% trav_out_edge %>% trav_in_node # Verify that the selection of node `2` has been # made by using the `get_selection()` function get_selection(graph) #> [1] "2"