Skip to content

Commit 5d53d05

Browse files
fix has_multi_edges (#75)
fix has_multi_edges
1 parent f337547 commit 5d53d05

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GraphNeuralNetworks"
22
uuid = "cffab07f-9bc2-4db1-8861-388f63bf7694"
33
authors = ["Carlo Lucibello and contributors"]
4-
version = "0.3.3"
4+
version = "0.3.4"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/GNNGraphs/query.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Return `true` if `g` has any multiple edges.
264264
"""
265265
function has_multi_edges(g::GNNGraph)
266266
s, t = edge_index(g)
267-
idxs = edge_encoding(s, t, g.num_nodes)
267+
idxs, _ = edge_encoding(s, t, g.num_nodes)
268268
length(union(idxs)) < length(idxs)
269269
end
270270

test/GNNGraphs/query.jl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
@testset "Query" begin
22
@testset "is_bidirected" begin
3-
g = rand_graph(10, 20, bidirected=true)
3+
g = rand_graph(10, 20, bidirected=true, graph_type=GRAPH_T)
44
@test is_bidirected(g)
55

6-
g = rand_graph(10, 20, bidirected=false)
6+
g = rand_graph(10, 20, bidirected=false, graph_type=GRAPH_T)
77
@test !is_bidirected(g)
88
end
9+
10+
@testset "has_multi_edges" begin
11+
if GRAPH_T == :coo
12+
s = [1, 1, 2, 3]
13+
t = [2, 2, 2, 4]
14+
g = GNNGraph(s, t, graph_type=GRAPH_T)
15+
@test has_multi_edges(g)
16+
17+
s = [1, 2, 2, 3]
18+
t = [2, 1, 2, 4]
19+
g = GNNGraph(s, t, graph_type=GRAPH_T)
20+
@test !has_multi_edges(g)
21+
end
22+
end
23+
24+
@testset "has_self_loops" begin
25+
s = [1, 1, 2, 3]
26+
t = [2, 2, 2, 4]
27+
g = GNNGraph(s, t, graph_type=GRAPH_T)
28+
@test has_self_loops(g)
29+
30+
s = [1, 1, 2, 3]
31+
t = [2, 2, 3, 4]
32+
g = GNNGraph(s, t, graph_type=GRAPH_T)
33+
@test !has_self_loops(g)
34+
end
935
end

0 commit comments

Comments
 (0)