| igraph Reference Manual |
|---|
int igraph_random_sample(igraph_vector_t *res, igraph_integer_t l, igraph_integer_t h, igraph_integer_t length);
This function generates an incresing sequence of random integer numbers from a given interval. The algorithm is taken literally from Jeffrey Scott Vitter: 'An Efficient Algorithm for Sequential Random Sampling', ACM Transactions on Mathematical Software, 13/1, 58--67. This method can be used for generating numbers from a very large interval, it is primilarly created for randomly selecting some edges from the sometimes huge set of possible edges in a large graph.
Arguments:
|
Pointer to an initialized vector, this will hold the result. It will be resized to the proper size. |
|
The lower limit of the generation interval (inclusive). |
|
The upper limit of the generation interval (inclusive). |
|
The number of random integers to generate. |
Returns:
Error code. |
Time complexity: according to the referenced paper, the expected running time is O(length).
| << 2. Random Sampling from Very Long Sequences | 3. Convex hull of a set of points on a plane >> |