Graphs.jl icon indicating copy to clipboard operation
Graphs.jl copied to clipboard

[bugfix] `Base.eltype` works on graph types as well as instances

Open lmondada opened this issue 3 years ago • 0 comments

According to the Julia documentation, eltype should be defined on the ::Type{AbstractGraph} instead of the instances themselves:

"The definition eltype(x) = eltype(typeof(x)) is provided for convenience so that instances can be passed instead of types. However the form that accepts a type argument should be defined for new types."

Currently, however:

julia> eltype(SimpleGraph{Int64})
Any

julia> eltype(SimpleGraph{Int64}())
Int64

This PR fixes this to return

julia> eltype(SimpleGraph{Int64})
Int64

lmondada avatar Jun 11 '22 20:06 lmondada