diff --git a/Project.toml b/Project.toml index 12acd18b1..b81560b53 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/GNNGraphs/query.jl b/src/GNNGraphs/query.jl index d100e05e6..7d8cd14a4 100644 --- a/src/GNNGraphs/query.jl +++ b/src/GNNGraphs/query.jl @@ -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 diff --git a/test/GNNGraphs/query.jl b/test/GNNGraphs/query.jl index 970f9b911..ed9005403 100644 --- a/test/GNNGraphs/query.jl +++ b/test/GNNGraphs/query.jl @@ -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