I'm having some trouble groking certain Tidygraph operations that are relatively straightforward in igraph.
In particular I would like to analyze specific neighborhoods at different orders. I think I need to use Morphs for this, but I just haven't got it working.
For example, say I have the following network structure:
I want to analyze the neighborhood about x.
library(tidygraph)
library(ggraph)
net <- tibble::tibble(A = letters[1:6],
B = rep(c("x", "y"), each = 3)) %>%
tidygraph::as_tbl_graph()
net %>%
ggraph(layout = "nicely") +
geom_edge_link() +
geom_node_point(size = 10, fill = "white", shape = 21) +
geom_node_text(aes(label = name)) +
theme_graph()
the iGraph implementation works as follows
Extract the neighborhood of node x.
v <- net %>%
tidygraph::as.igraph() %>%
igraph::neighborhood(nodes = "x", order = 1)
build a subgraph by unlisting the igraph.vs object
igraph::induced_subgraph(net, vids = unlist(v)) %>%
tidygraph::as_tbl_graph() %>%
ggraph(layout = "nicely") +
geom_edge_link() +
geom_node_point(size = 10, fill = "white", shape = 21) +
geom_node_text(aes(label = name)) +
theme_graph()
How do I do this with tidygraph? Morphs?