get_selection: Get the current selection available in a graph object

Description Usage Arguments Value Examples

View source: R/get_selection.R

Description

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

Usage

1

Arguments

graph

a graph object of class dgr_graph.

Value

a vector with the current selection of nodes or edges.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Create a simple graph
graph <-
  create_graph() %>%
  add_n_nodes(n = 6) %>%
  add_edge(
    from = 1,
    to = 2) %>%
  add_edge(
    from = 1,
    to = 3) %>%
  add_edge(
    from = 3,
    to = 4) %>%
  add_edge(
    from = 4,
    to = 5) %>%
  add_edge(
    from = 4,
    to = 6)

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

# Select edges associated with node `4` and return
# the selection of edges
graph %>%
  select_edges_by_node_id(nodes = 4) %>%
  get_selection()
#> [1] 3 4 5

DiagrammeR documentation built on Sept. 7, 2017, 1:06 a.m.