Skip to content

Commit

Permalink
remove rng, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
stecrotti committed Sep 27, 2024
1 parent 3e4dc49 commit 91d72fc
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions test/bipartite.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Graphs, IndexedGraphs, SparseArrays, Random
using Graphs, IndexedGraphs, SparseArrays

@testset "bipartite graph" begin
nl = 15
Expand Down Expand Up @@ -66,38 +66,37 @@ using Graphs, IndexedGraphs, SparseArrays, Random
end

@testset "bipartite generators" begin
rng = MersenneTwister(0)
ngraphs = 20
nrights = rand(rng, 5:50, ngraphs)
nlefts = rand(rng, 5:50, ngraphs)
es = [rand(rng, 1:n*m) for (n, m) in zip(nrights, nlefts)]
nrights = rand(5:50, ngraphs)
nlefts = rand(5:50, ngraphs)
es = [rand(1:n*m) for (n, m) in zip(nrights, nlefts)]

@testset "Random bipartite graph - fixed # edges" begin
@test all(zip(nrights, nlefts, es)) do (n, m, e)
g = rand_bipartite_graph(rng, m, n, e)
g = rand_bipartite_graph(m, n, e)
nv_right(g) == n && nv_left(g) == m && ne(g) == e
end
end

@testset "Random bipartite graph - prob of edges" begin
p = 0.1
@test all(zip(nrights, nlefts)) do (n, m)
g = rand_bipartite_graph(rng, n, m, p)
g = rand_bipartite_graph(m, n, p)
nv_right(g) == n && nv_left(g) == m
end
end

@testset "Random regular bipartite graph" begin
k = 4
@test all(zip(nrights, nlefts)) do (n, m)
g = rand_regular_bipartite_graph(rng, n, m, k)
g = rand_regular_bipartite_graph(m, n, k)
nv_right(g) == n && nv_left(g) == m && ne(g) == m * k
end
end

@testset "Random bipartite tree" begin
@test all(nrights) do n
g = rand_bipartite_tree(rng, n)
g = rand_bipartite_tree(n)
nv(g) == n && !is_cyclic(g)
end
end
Expand Down

0 comments on commit 91d72fc

Please sign in to comment.