RNG_BEGIN();
for (igraph_integer_t i=0; i < trunc(0.005 * igraph_ecount(&g)); i++) {
- VECTOR(weights)[RNG_INTEGER(0, igraph_ecount(&g)-1)] = RNG_UNIF(-0.05, 0);
+ /* For reproducibility, do not write two RNG_...() calls on the same line
+ * as the C language does not guarantee any evaluation order between them. */
+ igraph_real_t w = RNG_UNIF(-0.05, 0);
+ VECTOR(weights)[RNG_INTEGER(0, igraph_ecount(&g)-1)] = w;
}
RNG_END();
RNG_BEGIN();
for (igraph_integer_t i=0; i < trunc(0.002 * igraph_ecount(&g)); i++) {
- VECTOR(weights)[RNG_INTEGER(0, igraph_ecount(&g)-1)] = RNG_UNIF(-0.02, 0);
+ /* For reproducibility, do not write two RNG_...() calls on the same line
+ * as the C language does not guarantee any evaluation order between them. */
+ igraph_real_t w = RNG_UNIF(-0.02, 0);
+ VECTOR(weights)[RNG_INTEGER(0, igraph_ecount(&g)-1)] = w;
}
RNG_END();
RNG_BEGIN();
for (igraph_integer_t i=0; i < trunc(0.01 * igraph_ecount(&g)); i++) {
- VECTOR(weights)[RNG_INTEGER(0, igraph_ecount(&g)-1)] = RNG_UNIF(-0.02, 0);
+ /* For reproducibility, do not write two RNG_...() calls on the same line
+ * as the C language does not guarantee any evaluation order between them. */
+ igraph_real_t w = RNG_UNIF(-0.02, 0);
+ VECTOR(weights)[RNG_INTEGER(0, igraph_ecount(&g)-1)] = w;
}
RNG_END();