Fastest way to get a random neighbor
Hi There, I was wondering what your thoughts were on the fastest way to get a random neighbor of a vertex? Right now I am doing something like: / outid = G.get_out_neighbours(v) outid = random.choice(outid)/ I'm trying to implement a type of random walk and have the above code wrapped in a for loop ~ 100000 iterations. Is there a better way to implement this? Thanks! -- Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
On 12.09.2017 17:30, balazshoranyi01 wrote:
Hi There,
I was wondering what your thoughts were on the fastest way to get a random neighbor of a vertex? Right now I am doing something like: / outid = G.get_out_neighbours(v) outid = random.choice(outid)/
I'm trying to implement a type of random walk and have the above code wrapped in a for loop ~ 100000 iterations. Is there a better way to implement this?
It is hard to suggest an improvement without further context. The first line is O(k) and the second is O(1), and they both are the best you can get. -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
balazshoranyi01 -
Tiago de Paula Peixoto