These three functions makes it possible to directly access either the node data, the edge data or the graph itself while computing inside verbs. It is e.g. possible to add an attribute from the node data to the edges based on the terminating nodes of the edge, or extract some statistics from the graph itself to use in computations.

.G()

.N(focused = TRUE)

.E(focused = TRUE)

Arguments

focused

Should only the attributes of the currently focused nodes or edges be returned

Value

Either a tbl_graph (.G()) or a tibble (.N())

Functions

  • .G(): Get the tbl_graph you're currently working on

  • .N(): Get the nodes data from the graph you're currently working on

  • .E(): Get the edges data from the graph you're currently working on

Examples


# Get data from the nodes while computing for the edges
create_notable('bull') %>%
  activate(nodes) %>%
  mutate(centrality = centrality_power()) %>%
  activate(edges) %>%
  mutate(mean_centrality = (.N()$centrality[from] + .N()$centrality[to])/2)
#> # A tbl_graph: 5 nodes and 5 edges
#> #
#> # An undirected simple graph with 1 component
#> #
#> # Edge Data: 5 × 3 (active)
#>    from    to mean_centrality
#>   <int> <int>           <dbl>
#> 1     1     2          -1.20 
#> 2     1     3          -1.20 
#> 3     2     3          -1.20 
#> 4     2     4          -0.896
#> 5     3     5          -0.896
#> #
#> # Node Data: 5 × 1
#>   centrality
#>        <dbl>
#> 1      -1.20
#> 2      -1.20
#> 3      -1.20
#> # ℹ 2 more rows