Skip to content

Try to fix GAT example by split utility dependency for SimpleGraph and SimpleWeightedGraphs #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/GeometricFlux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export
feature,
nv,

# graph/utils
# graph/simplegraphs
adjlist,

# utils
Expand Down Expand Up @@ -151,7 +151,6 @@ function __init__()
end
@require SimpleWeightedGraphs = "47aef6b3-ad0c-573a-a1e2-d07658019622" begin
include("graph/weightedgraphs.jl")
include("graph/utils.jl")
end
@require MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5" begin
include("graph/metagraphs.jl")
Expand Down
8 changes: 7 additions & 1 deletion src/graph/simplegraphs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using LightGraphs: AbstractSimpleGraph, nv, adjacency_matrix, inneighbors, outneighbors, all_neighbors
using LightGraphs: AbstractSimpleGraph, nv, adjacency_matrix, inneighbors, outneighbors,
all_neighbors

function adjlist(g::AbstractSimpleGraph)
N = nv(g)
Vector{Int}[outneighbors(g, i) for i = 1:N]
end

## Convolution layers accepting AbstractSimpleGraph

Expand Down
14 changes: 0 additions & 14 deletions src/graph/utils.jl

This file was deleted.

7 changes: 6 additions & 1 deletion src/graph/weightedgraphs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using SimpleWeightedGraphs: AbstractSimpleWeightedGraph, nv
using SimpleWeightedGraphs: AbstractSimpleWeightedGraph, nv, outneighbors

function adjlist(g::AbstractSimpleWeightedGraph)
N = nv(g)
Vector{Int}[outneighbors(g, i) for i = 1:N]
end

## Convolution layers accepting AbstractSimpleWeightedGraph

Expand Down
11 changes: 11 additions & 0 deletions test/graph/simplegraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ ug = SimpleGraph(6)
add_edge!(ug, 1, 2); add_edge!(ug, 1, 3); add_edge!(ug, 2, 3)
add_edge!(ug, 3, 4); add_edge!(ug, 2, 5); add_edge!(ug, 3, 6)

dg = SimpleDiGraph(6)
add_edge!(dg, 1, 3); add_edge!(dg, 2, 3); add_edge!(dg, 1, 6)
add_edge!(dg, 2, 5); add_edge!(dg, 3, 4); add_edge!(dg, 3, 5)

el_ug = Vector{Int64}[[2, 3], [1, 3, 5], [1, 2, 4, 6], [3], [2], [3]]
el_dg = Vector{Int64}[[3, 6], [3, 5], [4, 5], [], [], []]

@testset "simplegraphs" begin
@testset "adjlist" begin
@test adjlist(ug) == el_ug
@test adjlist(dg) == el_dg
end

@testset "linalg" begin
for T in [Int8, Int16, Int32, Int64, Int128]
@test degree_matrix(adj, T, dir=:out) == T.(deg)
Expand Down
24 changes: 0 additions & 24 deletions test/graph/utils.jl

This file was deleted.

11 changes: 11 additions & 0 deletions test/graph/weightedgraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ ug = SimpleWeightedGraph(6)
add_edge!(ug, 1, 2, 2); add_edge!(ug, 1, 3, 2); add_edge!(ug, 2, 3, 1)
add_edge!(ug, 3, 4, 5); add_edge!(ug, 2, 5, 2); add_edge!(ug, 3, 6, 2)

dg = SimpleWeightedDiGraph(6)
add_edge!(dg, 1, 3, 2); add_edge!(dg, 2, 3, 2); add_edge!(dg, 1, 6, 1)
add_edge!(dg, 2, 5, -2); add_edge!(dg, 3, 4, -2); add_edge!(dg, 3, 5, -1)

el_ug = Vector{Int64}[[2, 3], [1, 3, 5], [1, 2, 4, 6], [3], [2], [3]]
el_dg = Vector{Int64}[[3, 6], [3, 5], [4, 5], [], [], []]

@testset "weightedgraphs" begin
@testset "adjlist" begin
@test adjlist(ug) == el_ug
@test adjlist(dg) == el_dg
end

@testset "linalg" begin
for T in [Int8, Int16, Int32, Int64, Int128]
@test degree_matrix(adj, T, dir=:out) == T.(deg)
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ tests = [
"graph/simplegraphs",
"graph/weightedgraphs",
"graph/metagraphs",
"graph/utils",
"utils",
]

Expand Down