get_edge_df: Get an edge data frame from a graph

Description Usage Arguments Value Examples

View source: R/get_edge_df.R

Description

From a graph, obtain an edge data frame with all current edge attributes.

Usage

1
get_edge_df(graph)

Arguments

graph

a graph object of class dgr_graph.

Value

an edge data frame.

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
# Create a graph using several piped functions
graph <-
  create_graph() %>%
  add_n_nodes(
    n = 1,
    type = "a") %>%
  select_last_nodes_created() %>%
  add_n_nodes_ws(
    n = 5,
    direction = "from",
    type = "b") %>%
  select_edges_by_node_id(nodes = 3:5) %>%
  set_edge_attrs_ws(
    edge_attr = color,
    value = "green") %>%
  set_edge_attrs_ws(
    edge_attr = rel,
    value = "a") %>%
  invert_selection %>%
  set_edge_attrs_ws(
    edge_attr = color,
    value = "blue") %>%
  set_edge_attrs_ws(
    edge_attr = rel,
    value = "b") %>%
  clear_selection()

# Get the graph's internal edge data frame (edf)
get_edge_df(graph)
#>   id from to rel color
#> 1  1    1  2   b  blue
#> 2  2    1  3   a green
#> 3  3    1  4   a green
#> 4  4    1  5   a green
#> 5  5    1  6   b  blue

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