View source: R/trav_out_until.R
From a graph object of class
dgr_graph, move along outward edges from one
or more nodes present in a selection to other connected nodes, replacing the
current nodes in the selection with those nodes traversed to until reaching
nodes that satisfy one or more conditions.
This traversal function makes use of an active selection of nodes. After the traversal, depending on the traversal conditions, there will either be a selection of nodes or no selection at all.
Selections of nodes can be performed using the following node selection
Selections of nodes can also be performed using the following traversal
trav_out_until( graph, conditions, max_steps = 30, exclude_unmatched = TRUE, add_to_selection = FALSE )
A graph object of class
An option to use a stopping condition for the traversal. If
the condition is met during the traversal (i.e., the node(s) traversed to
match the condition), then those traversals will terminate at those nodes.
Otherwise, traversals with continue and terminate when the number of steps
The maximum number of
A graph object of class
# Create a path graph and add # values of 1 to 10 across the # nodes from beginning to end; # select the first path node graph <- create_graph() %>% add_path( n = 10, node_data = node_data( value = 1:10)) %>% select_nodes_by_id( nodes = 1) # Traverse outward, node-by-node # until stopping at a node where # the `value` attribute is 8 graph <- graph %>% trav_out_until( conditions = value == 8) # Get the graph's node selection graph %>% get_selection() # Create two cycles in graph and # add values of 1 to 6 to the # first cycle, and values 7 to # 12 in the second; select nodes # `1` and `7` graph <- create_graph() %>% add_cycle( n = 6, node_data = node_data( value = 1:6)) %>% add_cycle( n = 6, node_data = node_data( value = 7:12)) %>% select_nodes_by_id( nodes = c(1, 7)) # Traverse outward, node-by-node # from `1` and `7` until stopping # at the first nodes where the # `value` attribute is 5, 6, or 15; # specify that we should only # keep the finally traversed to # nodes that satisfy the conditions graph <- graph %>% trav_out_until( conditions = value %in% c(5, 6, 9), exclude_unmatched = TRUE) # Get the graph's node selection graph %>% get_selection()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.