Is dijkstra_shortest_paths only supposed to handle integer weights?

Hi everyone,

I need to have float weight on a graph as it is used as a pricing problem for column generation.
As far as i can see the dijkstra_shortest_paths should be able use float weight, but when i try the following:

g = MetaGraph(2,0)

I get an inexact error:

InexactError: Int64(5.9)
in top-level scope at graphs.jl:50
in dijkstra_shortest_paths at LightGraphs\HsNig\src\shortestpaths\dijkstra.jl:143
in dijkstra_shortest_paths at LightGraphs\HsNig\src\shortestpaths\dijkstra.jl:143 
in #dijkstra_shortest_paths#106 at base\none 
in #dijkstra_shortest_paths#105 at LightGraphs\HsNig\src\shortestpaths\dijkstra.jl:95
in getindex at MetaGraphs\V2aXW\src\MetaGraphs.jl:199
in Int64 at base\float.jl:709

I might be wrong but i shouldn’t the following part that fails be able to handle floats?:

function getindex(w::MetaWeights{T,U}, u::Integer, v::Integer)::U where T <: Integer where U <: Real
    _e = Edge(u, v)
    e = !w.directed && !LightGraphs.is_ordered(_e) ? reverse(_e) : _e
    !haskey(w.eprops, e) && return w.defaultweight
    return U(get(w.eprops[e], w.weightfield, w.defaultweight))

Is this a bug or should i fint another way to do what i need to do? If so, do anyone have suggestions what to use?

0.0 ?

Wow, thanks! That seems to solve it :slight_smile:

1 Like