Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C kwarg failing in spring_layout #154

Closed
SimonEnsemble opened this issue Sep 6, 2021 · 1 comment
Closed

C kwarg failing in spring_layout #154

SimonEnsemble opened this issue Sep 6, 2021 · 1 comment

Comments

@SimonEnsemble
Copy link

the following code fails:

# make a graph with three connected components
graph = SimpleGraph(9)
add_edge!(graph, 1, 2)

add_edge!(graph, 3, 4)
add_edge!(graph, 3, 5)
add_edge!(graph, 4, 5)

add_edge!(graph, 6, 7)
add_edge!(graph, 7, 8)
add_edge!(graph, 8, 9)

loc_x, loc_y = spring_layout(graph, 97339, C=2.0)

with the error:

MethodError: no method matching setindex!(::Int64, ::Float64, ::Int64)

    var"#spring_layout#2"(::Float64, ::Int64, ::Float64, ::typeof(GraphPlot.spring_layout), ::LightGraphs.SimpleGraphs.SimpleGraph{Int64}, ::Int64, ::Vector{Float64})@layout.jl:158
    top-level scope@Local: 2[inlined]

but works just fine when I omit the C=2.0. (I am setting the random seed as 97339.

hdavid16 added a commit to hdavid16/GraphPlot.jl that referenced this issue Jul 27, 2022
Multiple dispatch was messing up because types were not specified for spring layout and `kws` not preceeded by `;`
hdavid16 added a commit to hdavid16/GraphPlot.jl that referenced this issue Aug 2, 2022
Multiple dispatch was messing up because types were not specified for spring layout and `kws` not preceeded by `;`
hdavid16 added a commit to hdavid16/GraphPlot.jl that referenced this issue Aug 2, 2022
This reverts commit 67bd950.
hdavid16 added a commit to hdavid16/GraphPlot.jl that referenced this issue Aug 5, 2022
@hdavid16
Copy link
Contributor

hdavid16 commented Apr 3, 2023

@SimonEnsemble this is fixed in PR #186. However, if you need to make plots where you set the seed, just use GraphMakie (since it is not clear if this PR will be merged at any point):

using Graphs, GraphMakie
using GraphMakie:Spring

graph = SimpleGraph(9)
add_edge!(graph, 1, 2)

add_edge!(graph, 3, 4)
add_edge!(graph, 3, 5)
add_edge!(graph, 4, 5)

add_edge!(graph, 6, 7)
add_edge!(graph, 7, 8)
add_edge!(graph, 8, 9)

graphplot(graph,layout=Spring(seed=97339,C=2.0))

image

If you just want the locations then run,

loc_x, loc_y = Spring(;C=2.0,seed=97339)(graph)

#9-element Vector{Point2{Float64}}:
# [6.085732446390886, 2.2914171065246642]
# [5.622402183255887, 1.0407819527554754]
# [1.5199667804243207, -8.373001182722112]
# [0.6096922018281642, -7.562980245682519]
# [2.013612134245273, -7.320345707757515]
# [-7.559104906247997, 5.12608753224364]
# [-6.192837350012484, 6.015599417248268]
# [-4.356427140564693, 6.320432042063193]
# [-2.8337673677147994, 6.923911898290827]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants