Graphviz 13.0.0~dev.20250424.1043
|
random number generation More...
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | UTIL_API /* nothing */ |
Functions | |
UTIL_API int * | gv_permutation (int bound) |
UTIL_API int | gv_random (int bound) |
UTIL_API uint64_t | gv_random_u64 (uint64_t bound) |
#define UTIL_API /* nothing */ |
hide the symbols this header declares by default
The expectation is that users of this header (applications, shared libraries, or static libraries) want to call gv_random
but not re-export it to their users. This annotation is only correct while the containing library is built statically. If it were built as a shared library, gv_random
would need to have default
visibility (and thus be unavoidably re-exported) in order to be callable.
UTIL_API int * gv_permutation | ( | int | bound | ) |
generate a random permutation of the numbers [0, bound - 1]
The caller is responsible for free
ing the returned array. This function calls exit
on memory allocation failure.
bound | Exclusive upper bound on the sequence |
[0, bound - 1]
Definition at line 13 of file random.c.
References gv_calloc(), gv_random(), NULL, and SWAP.
Referenced by maximal_independent_edge_set_heavest_edge_pernode_supernodes_first().
UTIL_API int gv_random | ( | int | bound | ) |
generate a random number in the range [0, bound - 1]
This function assumes the caller has previously seeded the rand
random number generator.
bound | Exclusive upper bound on random number generation |
Definition at line 83 of file random.c.
References gv_random_u64(), and random_small().
Referenced by gv_permutation(), and node_distinct_coloring_internal().
UTIL_API uint64_t gv_random_u64 | ( | uint64_t | bound | ) |
generate a random 64-bit unsigned number in the range [0, bound - 1]
This function assumes the caller has previously seeded the rand
random number generator.
bound | Exclusive upper bound on random number generation |
Definition at line 59 of file random.c.
References random_small(), and UINT8_MAX.
Referenced by genTree(), and gv_random().