You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/order.jl
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -33,22 +33,42 @@ function vertices(bg::BipartiteGraph, ::Val{side}, ::NaturalOrder) where {side}
33
33
end
34
34
35
35
"""
36
-
RandomOrder(rng=default_rng())
36
+
RandomOrder(rng=default_rng(), seed=nothing)
37
37
38
-
Instance of [`AbstractOrder`](@ref) which sorts vertices using a random permutation.
38
+
Instance of [`AbstractOrder`](@ref) which sorts vertices using a random permutation, generated from `rng` with a given `seed`.
39
+
40
+
- If `seed = nothing`, the `rng` will never be re-seeded. Therefore, two consecutive calls to `vertices(g, order)` will give different results.
41
+
- Otherwise, the `rng` will be re-seeded before each sample. Therefore, two consecutive calls to `vertices(g, order)` will give the same result.
42
+
43
+
!!! warning
44
+
Do not use a seed with the `default_rng()`, otherwise you will affect the global state of your program.
45
+
If you need reproducibility, create a new `rng` specifically for your `RandomOrder`.
46
+
The package [StableRNGs.jl](https://github.com/JuliaRandom/StableRNGs.jl) offers random number generators whose behavior is stable across Julia versions.
0 commit comments