# How to seed the \`random\_layout\` in the GraphPlot package?

**URL:** https://discourse.julialang.org/t/how-to-seed-the-random-layout-in-the-graphplot-package/86015
**Category:** Visualization
**Tags:** question, visualization, graphs
**Created:** [August 19, 2022, 3:20pm UTC](https://discourse.julialang.org/t/how-to-seed-the-random-layout-in-the-graphplot-package/86015 "2022-08-19T15:20:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)
#### Post date: [August 19, 2022, 3:20pm UTC](https://discourse.julialang.org/t/how-to-seed-the-random-layout-in-the-graphplot-package/86015/1 "2022-08-19T15:20:28Z")

</div>

Can I seed the `random_layout` when using the `GraphPlot` package to visualize a graph? For example:

```julia
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))

```

---

<div class="post-metadata">

### Author: ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)
#### Post date: [August 19, 2022, 3:46pm UTC](https://discourse.julialang.org/t/how-to-seed-the-random-layout-in-the-graphplot-package/86015/2 "2022-08-19T15:46:49Z")

</div>

I think I figured it out. May be I can save the `loc_x` and `loc_y` apriori:

```julia
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`.
