Last chance! 50% off unlimited learning
Sale ends in
dgr_graph
move to outgoing edges from a
selection of one or more selected nodes, thereby
creating a selection of edges. An optional filter by
edge attribute can limit the set of edges traversed
to.
trav_out_edge(graph, edge_attr = NULL, match = NULL)
dgr_graph
that is created using
create_graph
.>
,
<
, ==
, or !=
) followed by a
number for numerical filtering, or, a character
string for filtering the edges returned through
string matching.dgr_graph
.
library(magrittr)
# Create a simple graph
graph <-
create_graph() %>%
add_n_nodes(4) %>%
add_edge(1, 2) %>%
add_edge(2, 3) %>%
add_edge(3, 4)
# Traverse from nodes `1` to to `4` by, in an
# alternating manner, moving from nodes onto edges,
# from edges onto nodes
graph <-
graph %>%
select_nodes_by_id(1) %>%
trav_out_edge %>%
trav_in_node %>%
trav_out_edge %>%
trav_in_node %>%
trav_out_edge %>%
trav_in_node
# Verify that the selection has been made by using
# the `get_selection()` function
get_selection(graph)
#> [1] "4"
Run the code above in your browser using DataLab