How can I find, in a directed graph, all vertices that can reach a set of other vertices with the igraph package in R?
I'm able to find them for a single vertex using (e.g. for all vertices that can reach vertex 4):
subcomponent(g, 4, mode="in")
However, how can I replace "4" with a set of many vertices with a similar result? If I give many vertices to the default function, it seems to return only vertices that can reach all the given vertices. I would like to find all vertices that can reach any of the given vertices...
Thanks
You could make the function
subcomponent
take a vector of arguments for the parameterv
:Which could also be done using an
apply
function or a loop