Skip to content

Can't create a GNNGraph over degenerate graph with just a single vertex #580

@oxinabox

Description

@oxinabox
julia> using GNNGraphs

julia> GNNGraph(([1], Int[]), graph_type=:coo)
ERROR: ArgumentError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] _empty_reduce_error()
    @ Base ./reduce.jl:319
  [2] reduce_empty(f::Function, T::Type)
    @ Base ./reduce.jl:320
  [3] mapreduce_empty(::typeof(identity), op::Function, T::Type)
    @ Base ./reduce.jl:369
  [4] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, ::Type{Int64})
    @ Base ./reduce.jl:358
  [5] reduce_empty_iter
    @ ./reduce.jl:381 [inlined]
  [6] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Int64}, ItrEltype::Base.HasEltype)
    @ Base ./reduce.jl:377
  [7] _mapreduce
    @ ./reduce.jl:429 [inlined]
  [8] _mapreduce_dim
    @ ./reducedim.jl:337 [inlined]
  [9] mapreduce
    @ ./reducedim.jl:329 [inlined]
 [10] _maximum
    @ ./reducedim.jl:987 [inlined]
 [11] _maximum
    @ ./reducedim.jl:986 [inlined]
 [12] maximum
    @ ./reducedim.jl:982 [inlined]
 [13] to_coo(coo::Tuple{Vector{Int64}, Vector{Int64}, Nothing}; dir::Symbol, num_nodes::Nothing, weighted::Bool, hetero::Bool)
    @ GNNGraphs ~/.julia/packages/GNNGraphs/qLIkY/src/convert.jl:35
 [14] to_coo
    @ ~/.julia/packages/GNNGraphs/qLIkY/src/convert.jl:29 [inlined]
 [15] GNNGraph(data::Tuple{…}; num_nodes::Nothing, graph_indicator::Nothing, graph_type::Symbol, dir::Symbol, ndata::Nothing, edata::Nothing, gdata::Nothing)
    @ GNNGraphs ~/.julia/packages/GNNGraphs/qLIkY/src/gnngraph.jl:131
 [16] GNNGraph
    @ ~/.julia/packages/GNNGraphs/qLIkY/src/gnngraph.jl:119 [inlined]
 [17] #GNNGraph#22
    @ ~/.julia/packages/GNNGraphs/qLIkY/src/gnngraph.jl:167 [inlined]
 [18] top-level scope
    @ REPL[43]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions