File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,12 @@ function GNNGraph(data::D;
127
127
@assert graph_type ∈ [:coo , :dense , :sparse ] " Invalid graph_type $graph_type requested"
128
128
@assert dir ∈ [:in , :out ]
129
129
130
+ if ndata != = nothing && num_nodes === nothing
131
+ # Infer num_nodes from ndata
132
+ # Should be more robust than inferring from data
133
+ num_nodes = numobs (ndata)
134
+ end
135
+
130
136
if graph_type == :coo
131
137
graph, num_nodes, num_edges = to_coo (data; num_nodes, dir)
132
138
elseif graph_type == :dense
@@ -151,7 +157,16 @@ function GNNGraph(data::D;
151
157
ndata, edata, gdata)
152
158
end
153
159
154
- GNNGraph (; kws... ) = GNNGraph (0 ; kws... )
160
+ function GNNGraph (; num_nodes = nothing , ndata = nothing , kws... )
161
+ if num_nodes === nothing
162
+ if ndata === nothing
163
+ num_nodes = 0
164
+ else
165
+ num_nodes = numobs (ndata)
166
+ end
167
+ end
168
+ return GNNGraph (num_nodes; ndata, kws... )
169
+ end
155
170
156
171
function (:: Type{<:GNNGraph} )(num_nodes:: T ; kws... ) where {T <: Integer }
157
172
s, t = T[], T[]
You can’t perform that action at this time.
0 commit comments