-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support weights when generating from SimpleWeightedGraph (#371)
* add simpleweightedgraph support * add test * add SimpleWeightedGraphs to runtests.jl * replace import for using as it's not python * change to extension * remove SimpleWeightedGraphs from deps * add PR review suggestions * add test * refinement * add PR review suggestions
- Loading branch information
Showing
5 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
ext/GraphNeuralNetworksSimpleWeightedGraphsExt/GraphNeuralNetworksSimpleWeightedGraphsExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module GraphNeuralNetworksSimpleWeightedGraphsExt | ||
|
||
using GraphNeuralNetworks | ||
using Graphs | ||
using SimpleWeightedGraphs | ||
|
||
function GraphNeuralNetworks.GNNGraph(g::T; kws...) where | ||
{T <: Union{SimpleWeightedGraph, SimpleWeightedDiGraph}} | ||
return GNNGraph(g.weights, kws...) | ||
end | ||
|
||
end #module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
.../GraphNeuralNetworksSimpleWeightedGraphsExt/GraphNeuralNetworksSimpleWeightedGraphsExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@testset "simple_weighted_graph" begin | ||
srcs = [1, 2, 1] | ||
dsts = [2, 3, 3] | ||
wts = [0.5, 0.8, 2.0] | ||
g = SimpleWeightedGraph(srcs, dsts, wts) | ||
gd = SimpleWeightedDiGraph(srcs, dsts, wts) | ||
gnn_g = GNNGraph(g) | ||
gnn_gd = GNNGraph(gd) | ||
@test get_edge_weight(gnn_g) == [0.5, 2, 0.5, 0.8, 2.0, 0.8] | ||
@test get_edge_weight(gnn_gd) == [0.5, 2, 0.8] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters