# Reverse the direction of selected edges in a graph using an edge selection

Source:`R/rev_edge_dir_ws.R`

`rev_edge_dir_ws.Rd`

Using a directed graph with a selection of edges as input, reverse the direction of those selected edges in input graph.

This function makes use of an active selection of edges (and the function
ending with `_ws`

hints at this).

Selections of edges can be performed using the following selection
(`select_*()`

) functions: `select_edges()`

, `select_last_edges_created()`

,
`select_edges_by_edge_id()`

, or `select_edges_by_node_id()`

.

Selections of edges can also be performed using the following traversal
(`trav_*()`

) functions: `trav_out_edge()`

, `trav_in_edge()`

,
`trav_both_edge()`

, or `trav_reverse_edge()`

.

## See also

Other edge creation and removal:
`add_edge()`

,
`add_edge_clone()`

,
`add_edge_df()`

,
`add_edges_from_table()`

,
`add_edges_w_string()`

,
`add_forward_edges_ws()`

,
`add_reverse_edges_ws()`

,
`copy_edge_attrs()`

,
`create_edge_df()`

,
`delete_edge()`

,
`delete_edges_ws()`

,
`delete_loop_edges_ws()`

,
`drop_edge_attrs()`

,
`edge_data()`

,
`join_edge_attrs()`

,
`mutate_edge_attrs()`

,
`mutate_edge_attrs_ws()`

,
`recode_edge_attrs()`

,
`rename_edge_attrs()`

,
`rescale_edge_attrs()`

,
`rev_edge_dir()`

,
`set_edge_attr_to_display()`

,
`set_edge_attrs()`

,
`set_edge_attrs_ws()`

## Examples

```
# Create a graph with a
# directed tree
graph <-
create_graph() %>%
add_balanced_tree(
k = 2, h = 2)
# Inspect the graph's edges
graph %>% get_edges()
#> [1] "1->2" "1->3" "2->4" "2->5" "3->6" "3->7"
# Select all edges associated
# with nodes `1` and `2`
graph <-
graph %>%
select_edges_by_node_id(
nodes = 1:2)
# Reverse the edge directions
# of the edges associated with
# nodes `1` and `2`
graph <-
graph %>%
rev_edge_dir_ws()
# Inspect the graph's edges
# after their reversal
graph %>% get_edges()
#> [1] "2->1" "3->1" "4->2" "5->2" "3->6" "3->7"
```