Just started working with the tidygraph and ggraph packages recently and have a relatively simple problem, though, oddly, cannot seem to find an easy solution. Within a network, how many nodes are connected down from a single parent? Would seem to be a fairly simple question, but have struggled to arrive at an answer, especially when there are multiple "parent/child" relationships that need to be unfolded.
# reproducible example -----------------
library(tidygraph)
library(ggraph)
library(tidyverse)
parent_child <- tribble(
~parent, ~child,
"a", "b",
"b", "c",
"b", "d",
"d", "e",
"d", "f",
"d", "g",
"g", "z"
)
# converted to a dendrogram ------------
parent_child %>%
as_tbl_graph() %>%
ggraph(layout = "dendrogram") +
geom_node_point() +
geom_node_text(aes(label = name),
vjust = -1,
hjust = -1) +
geom_edge_elbow()
What I want to know; how many nodes are connected to point "b" when moving out/down (ignoring node "a")? The answer I would expect is 6, or, including "b", then 7.
I am running this over a network of about 5000 individuals, so filtering individual nodes by name is not a great solution. No one else in my office is familiar with network analyses, so have been kind of left on my own to figure this out. Really hope someone has an insight! In the mean time will keep reviewing the problem and possible solutions :) Thank y'all!