-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
This is a nice package for plotting graphs! I'm having some difficulty plotting a SimpleWeightedGraph
from SimpleWeightedGraphs.jl
and I'm getting an error for some graphs but not others (I'm generating them randomly at the moment).
When I convert the graphs to an unweighted SimpleGraph
the plotting works fine, so it seems there is some issue with weighted graphs – but it is inconsistent as some graphs plot and others have an error.
Example code to reproduce the bug:
using Random, LightGraphs, SimpleWeightedGraphs, GraphPlot
Random.seed!(23928)
n_nodes = 10
n_edges = 20
G = SimpleWeightedGraph(n_nodes)
for ii=1:n_edges
n1 = rand(1:n_nodes)
n2 = rand(1:n_nodes)
weight = rand()
add_edge!(G, n1, n2, weight)
end
gplot(G, layout=spectral_layout)
Running this code I get the following error:
BoundsError: attempt to access 17-element Vector{Vector{Tuple{Float64, Float64}}} at index [18]
Stacktrace:
[1] setindex!
@ ./array.jl:839 [inlined]
[2] graphline(g::SimpleWeightedGraph{Int64, Float64}, locs_x::Vector{Float64}, locs_y::Vector{Float64}, nodesize::Float64)
@ GraphPlot ~/.julia/packages/GraphPlot/vrIy8/src/lines.jl:73
[3] gplot(g::SimpleWeightedGraph{Int64, Float64}, locs_x_in::Vector{Float64}, locs_y_in::Vector{Float64}; nodelabel::Nothing, nodelabelc::ColorTypes.RGB{FixedPointNumbers.N0f8}, nodelabelsize::Float64, NODELABELSIZE::Float64, nodelabeldist::Float64, nodelabelangleoffset::Float64, edgelabel::Vector{Any}, edgelabelc::ColorTypes.RGB{FixedPointNumbers.N0f8}, edgelabelsize::Float64, EDGELABELSIZE::Float64, edgestrokec::ColorTypes.RGB{FixedPointNumbers.N0f8}, edgelinewidth::Float64, EDGELINEWIDTH::Float64, edgelabeldistx::Float64, edgelabeldisty::Float64, nodesize::Float64, NODESIZE::Float64, nodefillc::ColorTypes.RGB{FixedPointNumbers.N0f8}, nodestrokec::Nothing, nodestrokelw::Float64, arrowlengthfrac::Float64, arrowangleoffset::Float64, linetype::String, outangle::Float64)
@ GraphPlot ~/.julia/packages/GraphPlot/vrIy8/src/plot.jl:215
[4] gplot(g::SimpleWeightedGraph{Int64, Float64}, locs_x_in::Vector{Float64}, locs_y_in::Vector{Float64})
@ GraphPlot ~/.julia/packages/GraphPlot/vrIy8/src/plot.jl:115
[5] gplot(g::SimpleWeightedGraph{Int64, Float64}; layout::typeof(spectral_layout), keyargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ GraphPlot ~/.julia/packages/GraphPlot/vrIy8/src/plot.jl:229
[6] top-level scope
@ In[6]:1
[7] eval
@ ./boot.jl:360 [inlined]
[8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1094
However, converting to an unweighted SimpleGraph works fine:
gplot(SimpleGraph(G), layout=spectral_layout)
Package versions:
"LightGraphs" => v"1.3.5"
"SimpleWeightedGraphs" => v"1.1.1"
"Compose" => v"0.9.2"
"GraphPlot" => v"0.4.4"
Metadata
Metadata
Assignees
Labels
No labels