[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [igraph] Getting all vertices reachable from a particular vertex

**From**: |
Tamás Nepusz |

**Subject**: |
Re: [igraph] Getting all vertices reachable from a particular vertex |

**Date**: |
Mon, 15 Apr 2013 22:21:24 +0200 |

>* I'm wondering what the most efficient/idiomatic way to get all vertices *
>* reachable from a given vertex.*
reachable_vertices = list(graph.bfsiter(source))
This will give you a list of Vertex objects. If you only need the indices, do
this:
reachable_vertex_indices = [v.index for v in graph.bfsiter(source)]
As a side-effect, the list will be sorted in increasing order of distance from
the source vertex.
--
T.