Skip to content

Commit

Permalink
fix has_multi_edges (#75)
Browse files Browse the repository at this point in the history
fix has_multi_edges
  • Loading branch information
CarloLucibello authored Nov 15, 2021
1 parent f337547 commit 5d53d05
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GraphNeuralNetworks"
uuid = "cffab07f-9bc2-4db1-8861-388f63bf7694"
authors = ["Carlo Lucibello and contributors"]
version = "0.3.3"
version = "0.3.4"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
2 changes: 1 addition & 1 deletion src/GNNGraphs/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Return `true` if `g` has any multiple edges.
"""
function has_multi_edges(g::GNNGraph)
s, t = edge_index(g)
idxs = edge_encoding(s, t, g.num_nodes)
idxs, _ = edge_encoding(s, t, g.num_nodes)
length(union(idxs)) < length(idxs)
end

Expand Down
30 changes: 28 additions & 2 deletions test/GNNGraphs/query.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
@testset "Query" begin
@testset "is_bidirected" begin
g = rand_graph(10, 20, bidirected=true)
g = rand_graph(10, 20, bidirected=true, graph_type=GRAPH_T)
@test is_bidirected(g)

g = rand_graph(10, 20, bidirected=false)
g = rand_graph(10, 20, bidirected=false, graph_type=GRAPH_T)
@test !is_bidirected(g)
end

@testset "has_multi_edges" begin
if GRAPH_T == :coo
s = [1, 1, 2, 3]
t = [2, 2, 2, 4]
g = GNNGraph(s, t, graph_type=GRAPH_T)
@test has_multi_edges(g)

s = [1, 2, 2, 3]
t = [2, 1, 2, 4]
g = GNNGraph(s, t, graph_type=GRAPH_T)
@test !has_multi_edges(g)
end
end

@testset "has_self_loops" begin
s = [1, 1, 2, 3]
t = [2, 2, 2, 4]
g = GNNGraph(s, t, graph_type=GRAPH_T)
@test has_self_loops(g)

s = [1, 1, 2, 3]
t = [2, 2, 3, 4]
g = GNNGraph(s, t, graph_type=GRAPH_T)
@test !has_self_loops(g)
end
end

2 comments on commit 5d53d05

@CarloLucibello
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/48812

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.4 -m "<description of version>" 5d53d0585c319e5f7dc574e2e393e52e8473146a
git push origin v0.3.4

Please sign in to comment.