Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Make sure SimpleGraph uses RNG (#1500)
Browse files Browse the repository at this point in the history
Co-authored-by: oisinfaust <[email protected]>
  • Loading branch information
oisinfaust and oisinfaust authored Dec 13, 2020
1 parent 616e715 commit ab65981
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/SimpleGraphs/generators/randgraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function SimpleGraph{T}(nv::Integer, ne::Integer; seed::Int=-1) where T <: Integ
tnv = T(nv)
maxe = div(Int(nv) * (nv - 1), 2)
@assert(ne <= maxe, "Maximum number of edges for this graph is $maxe")
ne > div((2 * maxe), 3) && return complement(SimpleGraph(tnv, maxe - ne))
ne > div((2 * maxe), 3) && return complement(SimpleGraph(tnv, maxe - ne, seed=seed))

rng = getRNG(seed)
g = SimpleGraph(tnv)
Expand Down Expand Up @@ -63,7 +63,7 @@ function SimpleDiGraph{T}(nv::Integer, ne::Integer; seed::Int=-1) where T <: Int
tnv = T(nv)
maxe = Int(nv) * (nv - 1)
@assert(ne <= maxe, "Maximum number of edges for this graph is $maxe")
ne > div((2 * maxe), 3) && return complement(SimpleDiGraph{T}(tnv, maxe - ne))
ne > div((2 * maxe), 3) && return complement(SimpleDiGraph{T}(tnv, maxe - ne, seed=seed))

rng = getRNG(seed)
g = SimpleDiGraph(tnv)
Expand Down
2 changes: 2 additions & 0 deletions test/simplegraphs/generators/randgraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
@test eltype(r2) == Int

@test SimpleGraph(10, 20, seed=3) == SimpleGraph(10, 20, seed=3)
@test SimpleGraph(10, 40, seed=3) == SimpleGraph(10, 40, seed=3)
@test SimpleDiGraph(10, 20, seed=3) == SimpleDiGraph(10, 20, seed=3)
@test SimpleDiGraph(10, 80, seed=3) == SimpleDiGraph(10, 80, seed=3)
@test SimpleGraph(10, 20, seed=3) == erdos_renyi(10, 20, seed=3)
@test ne(Graph(10, 40, seed=3)) == 40
@test ne(DiGraph(10, 80, seed=3)) == 80
Expand Down

0 comments on commit ab65981

Please sign in to comment.