Convert current environment to tidygraph object
Source:R/environment_network.R
convert_network_to_tidygraph.RdConvert current environment to tidygraph object
Examples
a <- create_agent() %>%
add_rule('connect to a random other agent',
.consequence = \(me, abm) {
me %>%
network_connect(get_random_agent(abm, me)) %>%
return()
})
create_network_environment(seed = 183468,
is_directed = TRUE) %>%
add_agents(a,
n = 5) %>%
init() %>%
tick() %>%
convert_network_to_tidygraph()
#> [1] "Tick 1 finished in 0.157 secs"
#> # A tbl_graph: 5 nodes and 5 edges
#> #
#> # A directed simple graph with 2 components
#> #
#> # A tibble: 5 × 1
#> name
#> <chr>
#> 1 A1
#> 2 A2
#> 3 A3
#> 4 A4
#> 5 A5
#> #
#> # A tibble: 5 × 2
#> from to
#> <int> <int>
#> 1 2 1
#> 2 3 1
#> 3 1 2
#> # ℹ 2 more rows