I have a big igraph object. For a given vertex of the directed graph, I am interested in listing the nodes at a distance less than d from the initial node. For instance if I am looking for the vertices within 3 steps from V0, the function would return a data frame containing in the first column the distance to the initial vertex and the second column would contain the name of the vertex.
level, vertex.name
0, V0
1, V23
1, V45
...
2, V12
...
3,V730
I tried using the function neighbors() of igraph (since I can specify the mode: in/out/all) but it only lists the first level vertices. Do I have to write a recursive function which uses neighbors() or is there a simpler way? I am using R.
Any help would be much appreciated!
As MrFlick points out, the ego() function from igraph does just that.
See the documentation for more detail: http://igraph.org/r/doc/ego.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With