You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One would expect the layout of the resulting plot to be a inner shell of connected nodes [1, 3, 5], and an outer shell of unconnected nodes [2, 4, 6]. However, the output is:
This is due to an error in the shell_layout function that is returning the x and y locations in the wrong order:
function shell_layout(g, nlist::Union{Nothing, Vector{Vector{Int}}} = nothing)
if nv(g) == 1
return [0.0], [0.0]
end
if nlist == nothing
nlist = [collect(1:nv(g))]
end
radius = 0.0
if length(nlist[1]) > 1
radius = 1.0
end
locs_x = Float64[] # <--
locs_y = Float64[] # <--
for nodes in nlist
# Discard the extra angle since it matches 0 radians.
θ = range(0, stop=2pi, length=length(nodes)+1)[1:end-1]
append!(locs_x, radius*cos.(θ)) # <--
append!(locs_y, radius*sin.(θ)) # <--
radius += 1.0
end
return locs_x, locs_y
end
The x and y locations are returned in the order of appearance in each node [1, 3, 5, 2, 4, 6] instead of numerical order [1, 2, 3, 4, 5, 6]. Changing the 4 marked lines will fix the error:
function shell_layout(g, nlist::Union{Nothing, Vector{Vector{Int}}} = nothing)
if nv(g) == 1
return [0.0], [0.0]
end
if nlist == nothing
nlist = [collect(1:nv(g))]
end
radius = 0.0
if length(nlist[1]) > 1
radius = 1.0
end
locs_x = zeros(size(g, 1)) # <--
locs_y = zeros(size(g, 1)) # <--
for nodes in nlist
# Discard the extra angle since it matches 0 radians.
θ = range(0, stop=2pi, length=length(nodes)+1)[1:end-1]
locs_x[nodes] = radius*cos.(θ) # <--
locs_y[nodes] = radius*sin.(θ) # <--
radius += 1.0
end
return locs_x, locs_y
end
The text was updated successfully, but these errors were encountered:
hdavid16
added a commit
to hdavid16/GraphPlot.jl
that referenced
this issue
Jul 27, 2022
One would expect the layout of the resulting plot to be a inner shell of connected nodes [1, 3, 5], and an outer shell of unconnected nodes [2, 4, 6]. However, the output is:
This is due to an error in the shell_layout function that is returning the x and y locations in the wrong order:
The x and y locations are returned in the order of appearance in each node [1, 3, 5, 2, 4, 6] instead of numerical order [1, 2, 3, 4, 5, 6]. Changing the 4 marked lines will fix the error:
The text was updated successfully, but these errors were encountered: