DiagrammeR (version 1.0.5)

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

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.

Details

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

Examples

Run this code
# NOT RUN {
# 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()

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

# }

Run the code above in your browser using DataLab