I have the following code:

type MinCutVisitor{T} <: AbstractMASVisitor
  graph::SimpleGraph
  parities::AbstractArray{Bool,1}
  colormap::Vector{Int}
  bestweight::T
  cutweight::T
  visited::Integer
  distmx::AbstractArray{T, 2}
  vertices::Vector{Int}
end

function MinCutVisitor{T}(graph::SimpleGraph, distmx::AbstractArray{T, 2})
  n = nv(graph)
  MinCutVisitor(
    graph,
    falses(n),
    zeros(Int,n),
    typemax(T),
    zero(T),
    zero(Int),
    distmx,
    @compat(Vector{Int}())
)
end


and up until June 30th the outer constructor was working in 0.4:

julia> g = Graph(8)
{8, 0} undirected graph


julia> LightGraphs.MinCutVisitor(g,spzeros(Float64,8,8))
LightGraphs.MinCutVisitor{Float64}({8, 0} undirected graph,Bool[false,false,
false,false,false,false,false,false],[0,0,0,0,0,0,0,0],Inf,0.0,0,8x8 sparse 
matrix with 0 Float64 entries:,Int64[])


Now it fails on Float64 but not with Int:

julia> LightGraphs.MinCutVisitor(g,spzeros(Float64,8,8))
ERROR: MethodError: `convert` has no method matching convert(::Type{
LightGraphs.MinCutVisitor{T}}, ::LightGraphs.Graph, ::BitArray{1}, ::Array{
Int64,1}, ::Float64, ::Float64, ::Int64, ::Base.SparseMatrix.SparseMatrixCSC
{Float64,Int64}, ::Array{Int64,1})
This may have arisen from a call to the constructor LightGraphs.
MinCutVisitor{T}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  LightGraphs.MinCutVisitor{T}(::Union{LightGraphs.Graph,LightGraphs.DiGraph
}, ::AbstractArray{Bool,1}, ::Array{Int64,1}, ::T, ::T, ::Integer, ::
AbstractArray{T,2}, ::Array{Int64,1})
  LightGraphs.MinCutVisitor{T}(::Union{LightGraphs.Graph,LightGraphs.DiGraph
}, ::AbstractArray{T,2})
  call{T}(::Type{T}, ::Any)
  ...
 in call at /Users/seth/.julia/v0.4/LightGraphs/src/maxadjvisit.jl:99


julia> LightGraphs.MinCutVisitor(g,spzeros(Int,8,8))
LightGraphs.MinCutVisitor{Int64}({8, 0} undirected graph,Bool[false,false,
false,false,false,false,false,false],[0,0,0,0,0,0,0,0],9223372036854775807,0
,0,8x8 sparse matrix with 0 Int64 entries:,Int64[])

However, if I remove the type parameterization from the outer constructor:

function MinCutVisitor(graph::SimpleGraph, distmx::AbstractArray)

  n = nv(graph)
  MinCutVisitor(
    graph,
    falses(n),
    zeros(Int,n),
    typemax(T),
    zero(T),
    zero(Int),
    distmx,
    @compat(Vector{Int}())
)
end


it works. Can someone tell me why this is?

Reply via email to