# Why do I keep getting a Method Error for Graphs package every time?

**URL:** https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004
**Category:** Graphs
**Tags:** lightgraphs, graphs
**Created:** [April 25, 2022, 6:00pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004 "2022-04-25T18:00:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Temi-Tory](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/temi-tory/32/29716_2.png) [@Temi-Tory](https://discourse.julialang.org/u/Temi-Tory)
#### Post date: [April 25, 2022, 6:00pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004/1 "2022-04-25T18:00:00Z")

</div>

Hello there,  
I am having a seemingly recurring issue here.  
Lets say I am working on a Julia file with graphs for a while and everything is going well. Then I close that file and don’t use it for ages, and then the next time I come back, I get this error related to the Graphs package. Every single time. I don’t know what is causing this, please help.  
It has become very frustrating as my work uses network graphs ALOT.  
I suspect it’s something I am doing.

But here is the error message I get:

```julia
MethodError: no method matching layout(::Spring{2, Float64}, ::SimpleDiGraph{Int64})
Closest candidates are:
  layout(::NetworkLayout.IterativeLayout, ::AbstractMatrix) at \NetworkLayout.jl:75       
  layout(::NetworkLayout.AbstractLayout, ::LightGraphs.AbstractGraph) 

```

Here is a snippet of my code to better explain

```julia
import Cairo,Fontconfig 
using Random, Graphs, GraphMakie, GLMakie, CairoMakie, DataFrames, DelimitedFiles, Distributions, MetaGraphs
using GraphMakie.NetworkLayout 
CairoMakie.activate!()

Random.seed!(2409);
system_data = readdlm("PrPm/16 NodeNetwork Adjacency matrix.csv", ',', header= false, Int);
system_matrix = Matrix(DataFrame(system_data, :auto));
system_graph= DiGraph(system_matrix)
Sources=[1,3,13]; link_reliability=0.9; Node_Priors = 1 #no node failure therefore node reliability = 1
    f, ax, p = graphplot(system_graph, #layout=SquareGrid(),
                arrow_size=[25 for i in 1:ne(system_graph)],
                nlabels= repr.(1:nv(system_graph)),    
                                                            
                node_color=[if i in Sources "blue" else "pink" end for i in 1:nv(system_graph)], #Use colours to identify sink vs source nodes                                      
                node_size=[20 for i in 1:nv(system_graph)])
                ax.yreversed = true 
                hidedecorations!(ax) # hides ticks, grid and lables 
                hidespines!(ax) # hide the frame 
    display(f)

```

What I have tried:

1. Running my code line by line to figure out where problem is. I believe the problem line to be: graph plot line here: `f, ax, p = graphplot(system_graph, #layout=SquareGrid(),`
2. Killing and restarting julia REPL
3. Updating Graphs package in package manager  
4.Restarting everything

---

<div class="post-metadata">

### Author: ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)
#### Post date: [April 25, 2022, 7:13pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004/2 "2022-04-25T19:13:06Z")

</div>

Most likely is due to incompatible packages. The following works just fine

```nohighlight
using Graphs, GraphMakie, GLMakie
using NetworkLayout
g = wheel_graph(10)
f, ax, p = graphplot(g, edge_width=[3 for i in 1:ne(g)],
    node_size=[10 for i in 1:nv(g)])

```

with the following versions:

```julia
 Status `~/Documents/FunArt/graphsmakie/Project.toml`
  [e9467ef8] GLMakie v0.5.5
  [1ecd5474] GraphMakie v0.3.4
  [86223c79] Graphs v1.6.0
  [46757867] NetworkLayout v0.4.4

```

---

<div class="post-metadata">

### Author: ![Temi-Tory](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/temi-tory/32/29716_2.png) [@Temi-Tory](https://discourse.julialang.org/u/Temi-Tory)
#### Post date: [April 25, 2022, 7:32pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004/3 "2022-04-25T19:32:10Z")

</div>

> [@lazarusA](#):
>
> ```julia
> using Graphs, GraphMakie, GLMakie
> using NetworkLayout
> g = wheel_graph(10)
> f, ax, p = graphplot(g, edge_width=[3 for i in 1:ne(g)],
> node_size=[10 for i in 1:nv(g)])
> 
> ```

Copying and pasting the above on my side gives me the same code. I went back to my julia package manager to check my package versions to compare to yours. My versions are:

GLMakie v0.4.5  
GraphMakie v0.2.3  
Graphs v1.6.0  
NetworkLayout v0.4.0

I wonder if the version mismatch is the cause,.  
The problem now is that when I call update to all three non-up-to-date packages in julia, its says no changes and doesn’t seem to find a new version for non of them.

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [April 25, 2022, 7:51pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004/4 "2022-04-25T19:51:18Z")

</div>

Your version of NetworkLayout is looking for LightGraphs - later versions look for Graphs…

---

<div class="post-metadata">

### Author: ![Temi-Tory](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/temi-tory/32/29716_2.png) [@Temi-Tory](https://discourse.julialang.org/u/Temi-Tory)
#### Post date: [April 25, 2022, 8:22pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004/5 "2022-04-25T20:22:19Z")

</div>

Thank you,  
Forcing an update by: `NetworkLayout@0.4.0 ` threw an error about AbstractPlotting package was preventing the update. By removing AbstractPlotting package, I was able to update and now my code is working as normal thank you very much.

For future reference, may I ask how you were able to deduce that the package version was the issue or was it by process of elimination?

Thank you again 🙂

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [April 25, 2022, 8:23pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004/6 "2022-04-25T20:23:17Z")

</div>

😀 Your first error message mentions LightGraphs …

---

<div class="post-metadata">

### Author: ![Temi-Tory](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/temi-tory/32/29716_2.png) [@Temi-Tory](https://discourse.julialang.org/u/Temi-Tory)
#### Post date: [April 25, 2022, 8:28pm UTC](https://discourse.julialang.org/t/why-do-i-keep-getting-a-method-error-for-graphs-package-every-time/80004/7 "2022-04-25T20:28:23Z")

</div>

Ohhh yes, that makes sense.  
This also gives me a much clearer understanding of these kinds of errors in the future.  
Thanks again for taking time to help 👍🏼
