DiagrammeR (version 0.9.0)

select_rev_edges_ws: Select any reverse edges from a selection of edges

Description

From an active selection of edges in a graph object of class dgr_graph, select any of the available reverse edges between the nodes common to the selected edges. For instance, if an active selection has the edge 1- 2 but there is also an (unselected) edge 2->1, then this function can either switch to the selection of 2->1, or, incorporate those edges in the active selection of edges.

Usage

select_rev_edges_ws(graph, add_to_selection = TRUE)

Arguments

graph

a graph object of class dgr_graph.

add_to_selection

an option to either add the reverse edges to the active selection of edges (the default case, as TRUE) or switch the active entirely to those reverse edges (FALSE).

Value

a graph object of class dgr_graph.

Examples

Run this code
# NOT RUN {
# Create a node data frame (ndf)
ndf <-
  create_node_df(
    n = 4,
    type = "basic",
    label = TRUE)

# Create an edge data frame (edf)
edf <-
  create_edge_df(
    from = c(1, 4, 2, 3, 3),
    to =   c(4, 1, 3, 2, 1))

# Create a graph with the ndf and edf
graph <-
  create_graph(
    nodes_df = ndf,
    edges_df = edf)

# Explicitly select the edges `1`->`4`
# and `2`->`3`
graph <-
  graph %>%
  select_edges(from = 1, to = 4) %>%
  select_edges(from = 2, to = 3)

# Add to the selection the reverse edge
# (`4`->`1`)
graph <-
  graph %>%
  select_rev_edges_ws()

# Get the current selection of edges
get_selection(graph)
#> [1] 1 2 3 4
# }

Run the code above in your browser using DataCamp Workspace