How tidygraph and dplyr work together
maintidygraph provides a tidy API for graph/network manipulation by treating a graph as two relational tables: one for node data and one for edge data.
It wraps igraph functionality into a dplyr-compatible interface. You use the activate() function to switch the context of your verbs between nodes and edges. Once activated, dplyr verbs like mutate() can be used to add properties to nodes or edges using graph algorithms that are context-aware.
library(tidygraph)
play_gnp(10, 0.5) %>%
activate(nodes) %>%
mutate(degree = centrality_degree()) %>%
activate(edges) %>%
mutate(centrality = centrality_edge_betweenness()) %>%
arrange(centrality)