James,
Thanks. Here's what I get:
julia> Graph(Int16(5))
ERROR: MethodError: `convert` has no method matching convert(::Type{
UnitRange{Int16}}, ::UnitRange{Int64})
This may have arisen from a call to the constructor UnitRange{Int16}(...),
since type constructors fall back to convert methods.
Closest candidates are:
convert{T}(::Type{T}, ::T)
On Thursday, March 19, 2015 at 2:17:17 PM UTC-7, James Fairbanks wrote:
>
> You left out the initialization code for the fields in your excerpt above.
> What happens when you call Graph(Int16(5))?
>
> On Friday, March 6, 2015 at 2:42:20 PM UTC-5, Seth wrote:
>>
>>
>>
>> I have
>>
>> abstract AbstractGraph{T<:Integer}
>>
>> type Graph{T}<:AbstractGraph{T}
>> vertices::UnitRange{T}
>> edges::Set{Edge{T}}
>> finclist::Vector{Vector{Edge{T}}} # [src]: ((src,dst), (src,dst),
>> (src,dst))
>> binclist::Vector{Vector{Edge{T}}} # [dst]: ((src,dst), (src,dst),
>> (src,dst))
>> end
>>
>> function Graph{T<:Integer}(n::T)
>>
>>
>>
>>
>>
>> and g = Graph(5) works and produces a graph of type Graph{Int64}, but g
>> = Graph{Int64}(5) produces
>>
>> ERROR: MethodError: `convert` has no method matching
>> convert(::Type{LightGraphs.Graph{Int64}}, ::Int64)
>>
>> This is a problem because I have
>>
>> function union{T<:AbstractGraph}(g::T, h::T)
>> gnv = nv(g)
>> r = T(gnv + nv(h))
>> for e in edges(g)
>> add_edge!(r,e)
>> end
>> for e in edges(h)
>> add_edge!(r, gnv+src(e), gnv+dst(e))
>> end
>> return r
>> end
>>
>>
>>
>> Which is failing on line 3 (in the creation of the graph).
>>
>> What's the proper way of creating the object from a parameterized type?
>> Thanks.
>>
>