Skip to content

Commit 0916223

Browse files
authored
Merge pull request #45 from ilancoulon/ic/fix-gat-example
Try to fix GAT example by split utility dependency for SimpleGraph and SimpleWeightedGraphs
2 parents 3a8cda8 + 08a3f04 commit 0916223

File tree

8 files changed

+36
-43
lines changed

8 files changed

+36
-43
lines changed

src/GeometricFlux.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export
9494
feature,
9595
nv,
9696

97-
# graph/utils
97+
# graph/simplegraphs
9898
adjlist,
9999

100100
# utils
@@ -151,7 +151,6 @@ function __init__()
151151
end
152152
@require SimpleWeightedGraphs = "47aef6b3-ad0c-573a-a1e2-d07658019622" begin
153153
include("graph/weightedgraphs.jl")
154-
include("graph/utils.jl")
155154
end
156155
@require MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5" begin
157156
include("graph/metagraphs.jl")

src/graph/simplegraphs.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using LightGraphs: AbstractSimpleGraph, nv, adjacency_matrix, inneighbors, outneighbors, all_neighbors
1+
using LightGraphs: AbstractSimpleGraph, nv, adjacency_matrix, inneighbors, outneighbors,
2+
all_neighbors
3+
4+
function adjlist(g::AbstractSimpleGraph)
5+
N = nv(g)
6+
Vector{Int}[outneighbors(g, i) for i = 1:N]
7+
end
28

39
## Convolution layers accepting AbstractSimpleGraph
410

src/graph/utils.jl

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/graph/weightedgraphs.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using SimpleWeightedGraphs: AbstractSimpleWeightedGraph, nv
1+
using SimpleWeightedGraphs: AbstractSimpleWeightedGraph, nv, outneighbors
2+
3+
function adjlist(g::AbstractSimpleWeightedGraph)
4+
N = nv(g)
5+
Vector{Int}[outneighbors(g, i) for i = 1:N]
6+
end
27

38
## Convolution layers accepting AbstractSimpleWeightedGraph
49

test/graph/simplegraphs.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,19 @@ ug = SimpleGraph(6)
3030
add_edge!(ug, 1, 2); add_edge!(ug, 1, 3); add_edge!(ug, 2, 3)
3131
add_edge!(ug, 3, 4); add_edge!(ug, 2, 5); add_edge!(ug, 3, 6)
3232

33+
dg = SimpleDiGraph(6)
34+
add_edge!(dg, 1, 3); add_edge!(dg, 2, 3); add_edge!(dg, 1, 6)
35+
add_edge!(dg, 2, 5); add_edge!(dg, 3, 4); add_edge!(dg, 3, 5)
36+
37+
el_ug = Vector{Int64}[[2, 3], [1, 3, 5], [1, 2, 4, 6], [3], [2], [3]]
38+
el_dg = Vector{Int64}[[3, 6], [3, 5], [4, 5], [], [], []]
3339

3440
@testset "simplegraphs" begin
41+
@testset "adjlist" begin
42+
@test adjlist(ug) == el_ug
43+
@test adjlist(dg) == el_dg
44+
end
45+
3546
@testset "linalg" begin
3647
for T in [Int8, Int16, Int32, Int64, Int128]
3748
@test degree_matrix(adj, T, dir=:out) == T.(deg)

test/graph/utils.jl

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/graph/weightedgraphs.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,19 @@ ug = SimpleWeightedGraph(6)
3030
add_edge!(ug, 1, 2, 2); add_edge!(ug, 1, 3, 2); add_edge!(ug, 2, 3, 1)
3131
add_edge!(ug, 3, 4, 5); add_edge!(ug, 2, 5, 2); add_edge!(ug, 3, 6, 2)
3232

33+
dg = SimpleWeightedDiGraph(6)
34+
add_edge!(dg, 1, 3, 2); add_edge!(dg, 2, 3, 2); add_edge!(dg, 1, 6, 1)
35+
add_edge!(dg, 2, 5, -2); add_edge!(dg, 3, 4, -2); add_edge!(dg, 3, 5, -1)
36+
37+
el_ug = Vector{Int64}[[2, 3], [1, 3, 5], [1, 2, 4, 6], [3], [2], [3]]
38+
el_dg = Vector{Int64}[[3, 6], [3, 5], [4, 5], [], [], []]
3339

3440
@testset "weightedgraphs" begin
41+
@testset "adjlist" begin
42+
@test adjlist(ug) == el_ug
43+
@test adjlist(dg) == el_dg
44+
end
45+
3546
@testset "linalg" begin
3647
for T in [Int8, Int16, Int32, Int64, Int128]
3748
@test degree_matrix(adj, T, dir=:out) == T.(deg)

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ tests = [
4141
"graph/simplegraphs",
4242
"graph/weightedgraphs",
4343
"graph/metagraphs",
44-
"graph/utils",
4544
"utils",
4645
]
4746

0 commit comments

Comments
 (0)