mercredi 26 juin 2019

Making Random Choices from multiple lists effectively

I'm implementing Wilson's Algorithm, which uses random walks along graphs. So, at every step, I currently do run random.random.choice on the list of neighbors of my current vertex. However, this is obviously slow. If I was making random choices from the same list repeatedly, I could use numpy's np.random.choice with a larger size, but since the length of neighbors is not the same for all vertices, I am not sure how to do this.




Aucun commentaire:

Enregistrer un commentaire