DiagrammeR (version 0.9.0)

rev_edge_dir: Reverse the direction of all edges in a graph

Description

Using a directed graph as input, reverse the direction of all edges in that graph.

Usage

rev_edge_dir(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
graph %>% get_edges()
#> [1] "1->2" "1->3" "2->4" "2->5"
#> [5] "3->6" "3->7"

# Reverse the edge directions such that edges
# are directed toward the root of the tree
graph <- graph %>% rev_edge_dir()

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

Run the code above in your browser using DataCamp Workspace