Skip to contents

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().

Usage

rev_edge_dir_ws(graph)

Arguments

graph

A graph object of class dgr_graph.

Value

A graph object of class dgr_graph.

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"