JuliaGraphs/GraphPlot.jl

Add support for SimpleWeightedGraphs

Closed this issue · 2 comments

gplot fails to plot a simple weighted directed graph. See below:

julia> x=SimpleWeightedDiGraph(2);

julia> add_edge!(x,1,2,0.5);

julia> gplot(x)
ERROR: MethodError: no method matching _src_index(::SimpleWeightedEdge{Int64,Float64}, ::SimpleWeightedDiGraph{Int64,Float64})
Closest candidates are:
  _src_index(::LightGraphs.SimpleGraphs.SimpleEdge, ::AbstractGraph) at C:\Users\HD\.julia\packages\GraphPlot\4prMP\src\GraphPlot.jl:42       
Stacktrace:
 [1] graphline(::SimpleWeightedDiGraph{Int64,Float64}, ::Array{Float64,1}, ::Array{Float64,1}, ::Float64, ::Float64, ::Float64) at C:\Users\HD\.julia\packages\GraphPlot\4prMP\src\lines.jl:29
 [2] gplot(::SimpleWeightedDiGraph{Int64,Float64}, ::Array{Float64,1}, 
::Array{Float64,1}; nodelabel::Nothing, nodelabelc::RGB{FixedPointNumbers.Normed{UInt8,8}}, nodelabelsize::Float64, NODELABELSIZE::Float64, nodelabeldist::Float64, nodelabelangleoffset::Float64, edgelabel::Array{Any,1}, edgelabelc::RGB{FixedPointNumbers.Normed{UInt8,8}}, edgelabelsize::Float64, EDGELABELSIZE::Float64, edgestrokec::RGB{FixedPointNumbers.Normed{UInt8,8}}, edgelinewidth::Float64, EDGELINEWIDTH::Float64, edgelabeldistx::Float64, edgelabeldisty::Float64, nodesize::Float64, NODESIZE::Float64, nodefillc::RGB{FixedPointNumbers.Normed{UInt8,8}}, nodestrokec::Nothing, nodestrokelw::Float64, arrowlengthfrac::Float64, arrowangleoffset::Float64, linetype::String, outangle::Float64) at C:\Users\HD\.julia\packages\GraphPlot\4prMP\src\plot.jl:206
 [3] gplot(::SimpleWeightedDiGraph{Int64,Float64}, ::Array{Float64,1}, 
::Array{Float64,1}) at C:\Users\HD\.julia\packages\GraphPlot\4prMP\src\plot.jl:115
 [4] gplot(::SimpleWeightedDiGraph{Int64,Float64}; layout::typeof(spring_layout), keyargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\HD\.julia\packages\GraphPlot\4prMP\src\plot.jl:224
 [5] gplot(::SimpleWeightedDiGraph{Int64,Float64}) at C:\Users\HD\.julia\packages\GraphPlot\4prMP\src\plot.jl:224

Is it possible that you are using an outdated version of GraphPlot? As far as I know the function _src_index is not used anywhere anymore. When I executed your commands on my computer I could draw a SimpleWeightedGraph.

You are correct. It works now.