Skip to content

Commit 1f80cb6

Browse files
add tests
1 parent 3daf120 commit 1f80cb6

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

GNNGraphs/src/abstracttypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
const COO_T = Tuple{T, T, V} where {T <: AbstractVector{<:Integer}, V <: AbstractVector}
2+
const COO_T = Tuple{T, T, V} where {T <: AbstractVector{<:Integer}, V <: Union{Nothing, AbstractVector}}
33
const ADJLIST_T = AbstractVector{T} where {T <: AbstractVector{<:Integer}}
44
const ADJMAT_T = AbstractMatrix
55
const SPARSE_T = AbstractSparseMatrix # subset of ADJMAT_T

GNNGraphs/src/generate.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
rand_graph(n, m; bidirected=true, seed=-1, edge_weight = nothing, kws...)
2+
rand_graph([rng,] n, m; bidirected=true, edge_weight = nothing, kws...)
33
44
Generate a random (Erdós-Renyi) `GNNGraph` with `n` nodes and `m` edges.
55
@@ -10,7 +10,7 @@ In any case, the output graph will contain no self-loops or multi-edges.
1010
A vector can be passed as `edge_weight`. Its length has to be equal to `m`
1111
in the directed case, and `m÷2` in the bidirected one.
1212
13-
Use a `seed > 0` for reproducibility.
13+
Pass a random number generator as the first argument to make the generation reproducible.
1414
1515
Additional keyword arguments will be passed to the [`GNNGraph`](@ref) constructor.
1616

GNNGraphs/src/transform.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ end
518518
Return a new graph obtained from `g` by adding random edges, based on a specified `perturb_ratio`.
519519
The `perturb_ratio` determines the fraction of new edges to add relative to the current number of edges in the graph.
520520
These new edges are added without creating self-loops.
521-
Optionally, a random `seed` can be provided to ensure reproducible perturbations.
522521
523522
The function returns a new `GNNGraph` instance that shares some of the underlying data with `g` but includes the additional edges.
524523
The nodes for the new edges are selected randomly, and no edge data (`edata`) or weights (`w`) are assigned to these new edges.

GNNGraphs/test/generate.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@
1616
@test g.edata.e[:, (m2 + 1):end] == e
1717
end
1818

19-
g = rand_graph(n, m, bidirected = false, seed = 17, graph_type = GRAPH_T)
19+
rng = MersenneTwister(17)
20+
g = rand_graph(rng, n, m, bidirected = false, graph_type = GRAPH_T)
2021
@test g.num_nodes == n
2122
@test g.num_edges == m
2223

23-
g2 = rand_graph(n, m, bidirected = false, seed = 17, graph_type = GRAPH_T)
24+
rng = MersenneTwister(17)
25+
g2 = rand_graph(rng, n, m, bidirected = false, graph_type = GRAPH_T)
2426
@test edge_index(g2) == edge_index(g)
2527

2628
ew = rand(m2)
27-
g = rand_graph(n, m, bidirected = true, seed = 17, graph_type = GRAPH_T, edge_weight = ew)
29+
rng = MersenneTwister(17)
30+
g = rand_graph(rng, n, m, bidirected = true, graph_type = GRAPH_T, edge_weight = ew)
2831
@test get_edge_weight(g) == [ew; ew] broken=(GRAPH_T != :coo)
2932

3033
ew = rand(m)
31-
g = rand_graph(n, m, bidirected = false, seed = 17, graph_type = GRAPH_T, edge_weight = ew)
34+
rng = MersenneTwister(17)
35+
g = rand_graph(n, m, bidirected = false, graph_type = GRAPH_T, edge_weight = ew)
3236
@test get_edge_weight(g) == ew broken=(GRAPH_T != :coo)
3337
end
3438

GNNGraphs/test/utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
end
9595

9696
@testset "color_refinment" begin
97-
g = rand_graph(10, 20, seed=17, graph_type = GRAPH_T)
97+
rng = MersenneTwister(17)
98+
g = rand_graph(rng, 10, 20, graph_type = GRAPH_T)
9899
x0 = ones(Int, 10)
99100
x, ncolors, niters = color_refinement(g, x0)
100101
@test ncolors == 8

0 commit comments

Comments
 (0)