Can I seed the random_layout
when using the GraphPlot
package to visualize a graph? For example:
using GraphPlot
using Graphs
using Compose
g = SimpleGraph()
add_vertices!(g,25)
for i in 1:10
for j in 11:25
add_edge!(g,i,j) end
end
end
draw(SVG("network.svg", 16cm, 16cm), gplot(g, layout = random_layout))
I think I figured it out. May be I can save the loc_x
and loc_y
apriori:
using GraphPlot
using Graphs
using Compose
g = SimpleGraph()
add_vertices!(g,25)
loc_x, loc_y = random_layout(g) #saving coordinates
for i in 1:10
for j in 11:25
add_edge!(g,i,j) end
end
end
draw(SVG("network.svg", 16cm, 16cm), gplot(g, loc_x, loc_y)) #Specify coordinates instead of layout
I can probably just save the loc_x
and loc_y
to some variable for use later. Not the most elegant way, but I guess it works for now. Ideally, random_layout
should accept a seed
.