DiagrammeR (version 0.9.0)

rev_edge_dir_ws: Reverse the direction of selected edges in a graph

Description

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

Usage

rev_edge_dir_ws(graph)

Arguments

graph

a graph object of class dgr_graph.

Value

a graph object of class dgr_graph.

Examples

Run this code
# NOT RUN {
# Create a graph with a directed tree
graph <-
  create_graph() %>%
  add_balanced_tree(2, 2)

# Inspect the graph's edges
get_edges(graph)
#> [1] "1->2" "1->3" "2->4" "2->5"
#> [5] "3->6" "3->7"

# Select all edges associated with
# nodes `1` and `2`
graph <- select_edges_by_node_id(graph, 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"
#> [5] "3->6" "3->7"
# }

Run the code above in your browser using DataLab