Hi, I hope this is the right place to post this. It’s sort of a followup to this question but on a somewhat different aspect.
In particular, I want to construct a SimpleWeightedGraph (which will eventually be passed to the constructor of a MetaGraph) that has integer edge weights. By default, they come out as Float64. In the source code, it seems like this should be possible:
"""
SimpleWeightedGraph{T, U}
A type representing an undirected graph with weights of type `U`.
Note that adding or removing vertices or edges is not particularly performant;
see MetaGraphs.jl for possible alternatives.
"""
mutable struct SimpleWeightedGraph{T<:Integer, U<:Real} <: AbstractSimpleWeightedGraph{T, U}
weights::SparseMatrixCSC{U,T}
function SimpleWeightedGraph{T, U}(adjmx::SparseMatrixCSC{U, T}) where T<:Integer where U<:Real
dima,dimb = size(adjmx)
isequal(dima,dimb) || error("Adjacency / distance matrices must be square")
issymmetric(adjmx) || error("Adjacency / distance matrices must be symmetric")
new{T, U}(adjmx)
end
end
However, when I try, it doesn’t seem to work. In particular, I’ve tried the following:
g = SimpleWeightedGraph(4, Integer)
g = SimpleWeightedGraph(4, Int64)
g = SimpleWeightedGraph(4, typeof(0))
among many others, and in all cases I get some variant of MethodError: no method matching...
like so:
ERROR: MethodError: no method matching SimpleWeightedGraph(::Int64, ::Type{Integer})
Closest candidates are:
SimpleWeightedGraph(::T<:Integer) where T<:Integer at /Users/rkurchin/.julia/packages/SimpleWeightedGraphs/yUFrc/src/simpleweightedgraph.jl:54
SimpleWeightedGraph(::Type{T<:Integer}, ::Type{U<:Real}) where {U<:Real, T<:Integer} at /Users/rkurchin/.julia/packages/SimpleWeightedGraphs/yUFrc/src/simpleweightedgraph.jl:60
SimpleWeightedGraph(::SimpleGraph{T<:Integer}, ::Type{U<:Real}) where {U<:Real, T<:Integer} at /Users/rkurchin/.julia/packages/SimpleWeightedGraphs/yUFrc/src/simpleweightedgraph.jl:63
I feel like this probably has a very simple answer, but I’ve run out of ideas. Any help would be appreciated!