get_selection {DiagrammeR}R Documentation

Get the current selection available in a graph object

Description

Get the current selection of nodes or edges from a graph object of class dgr_graph.

Usage

get_selection(graph)

Arguments

graph

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

Value

a list object with the current selection of nodes or edges.

Examples

## Not run: 
library(magrittr)

# Create a simple graph
graph <-
  create_graph() %>%
  add_node_df(create_nodes(1:6)) %>%
  add_edge("1", "2") %>% add_edge("1", "3") %>%
  add_edge("3", "4") %>% add_edge("4", "5") %>%
  add_edge("4", "6")

# Select node "4", select all nodes a distance of 1 away from "4",
# and return the selection of nodes as a list object
graph %>% select_nodes(nodes = "4") %>%
  select_nodes_in_neighborhood(node = "4", distance = 1) %>%
  get_selection()
#> $nodes
#> [1] "4" "5" "6" "3"

## End(Not run)

[Package DiagrammeR version 0.8.2 Index]