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

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:

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

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

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

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:

 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

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.

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

1 Like

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 :slight_smile:

:grinning: Your first error message mentions LightGraphs …

1 Like

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 :+1:t3:

1 Like