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!
ego()
function. It can list nodes that are a certain distance from a given node. It would be easier to give you a more specific solution if you provide a proper reproducible example – MrFlick