CarloLucibello / GraphNeuralNetworks.jl

Graph Neural Networks in Julia
https://carlolucibello.github.io/GraphNeuralNetworks.jl/dev/
MIT License
214 stars 47 forks source link

`add_edges` adds a non-existent edge to its `DataStore` #280

Closed bicycle1885 closed 1 year ago

bicycle1885 commented 1 year ago
julia> using GraphNeuralNetworks

julia> g = GNNGraph([1], [2])
GNNGraph:
  num_nodes: 2
  num_edges: 1

julia> h = add_edges(g, Int[], Int[])  # adds no edges
GNNGraph:
  num_nodes: 2
  num_edges: 1

julia> g.edata._n  # this is one, of course
1

julia> h.edata._n  # but this is two, which is unexpected
2

I tested this on Julia 1.8.5 and the latest master branch of GraphNeuralNetworks.jl.

bicycle1885 commented 1 year ago

Obviously this is cased by these lines, but I have no idea why we need them. https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/4e33163af67759ca45fbd461c383407260c56896/src/GNNGraphs/datastore.jl#L183-L184

CarloLucibello commented 1 year ago

I don't remember the reason for those cheks, I'll investigate