Learn R Programming

DiagrammeR (version 0.8.4)

select_last_edge: Select last edge in a series of edges defined in a graph

Description

Select the last edge from a graph object of class dgr_graph. Strictly, this is the edge definition that encompasses the last record of the graph's edge data frame. In practice, this will typically be the last edge created.

Usage

select_last_edge(graph)

Arguments

graph
a graph object of class dgr_graph that is created using create_graph.

Value

a graph object of class dgr_graph.

Examples

Run this code
library(magrittr)

# Create an empty graph
graph <- create_graph()

# Add three nodes to the graph
graph %<>% add_n_nodes(3)

# Add two edges to the graph
graph %<>%
  add_edge(1, 2) %>%
  add_edge(2, 3)

# Select the last edge added
graph %<>% select_last_edge

# Get the current selection
graph %>% get_selection
#> $edges
#> $edges$from
#> [1] "2"
#>
#> $edges$to
#> [1] "3"

Run the code above in your browser using DataLab