random permutation with Fisher-Yates shuffle
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
igraph |
Fix Released
|
Undecided
|
Gábor Csárdi |
Bug Description
A C implementation of the Fisher-Yates shuffle. This algorithm is also known as the Knuth shuffle and is used for producing random permutations of sequences. The algorithm has a theoretical runtime of O(n), where n is the length of the input sequence.
The attached patch is a pre-requisite for further patches on game theory on graphs that I'm working on, in particular the following ticket:
https:/
Some game update procedures require that in case multiple candidates can be chosen for update, we need to choose one such candidate at random. The Fisher-Yates shuffle can be used to randomize the order in which candidates are to be updated. See the following blog post for a statistical analysis of the C implementation contained in the patch:
http://
Related branches
description: | updated |
Added in revision #2441, after slight changes, mostly cosmetics.
RNG_BEGIN/RNG_END is not part of the igraph API, the user is not supposed to call it. The RNG_INTEGER(), etc. macros are also internal, they will be moved to an internal header file, at some point.