
21 Dec
2011
21 Dec
'11
12:09 a.m.
On Tue, 20 Dec 2011, George Bezerra wrote:
Hi, I'm totally new to BGL. I would like to know what is the best way to select a random neighbor of a vertex in an undirected graph without having to iterate through all neighbors. Can anyone help me with that? Thanks!
There is an out_degree() function you can call, then use a random number from 0 to that value to index a particular outgoing edge. Use std::advance for counting to take advantage of out_edge_iterator types that directly support random access (not all do). -- Jeremiah Willcock