JuliaGraphs / GraphPlot.jl

Graph visualization for Julia.
http://JuliaGraphs.github.io/GraphPlot.jl/
Other
200 stars 62 forks source link

allow `gplot` to set `seed` for `spring_layout` #153

Closed SimonEnsemble closed 2 years ago

SimonEnsemble commented 2 years ago

I often need to redraw the same graph (via spring layout) multiple times but with different colors on the nodes.

an optimal argument seed to allow me to set the seed inside spring_layout would be helpful so the layout doesn't change each time I re-run gplot.

currently, I must do:

using Random
Random.seed!(97330)
gplot(my_graph)
afternone commented 2 years ago

You can give the location of nodes to gplot as follows:

loc_x, loc_y = spring_layout(g)
gplot(g, loc_x=loc_x, loc_y=loc_y)
SimonEnsemble commented 2 years ago

thanks. the above didn't work for me, but this does:

loc_x, loc_y = spring_layout(graph, 97330) # seed is 97330

gplot(graph, loc_x, loc_y)