Basic plot function in NetworkLayout.jl not working

I am having trouble executing even the most basic commands in the NetworkLayout package. The following code is verbatim from the package’s documentation page.

using CairoMakie
using NetworkLayout
using GraphMakie, LightGraphs
adj_matrix = [0 1 1 0 0 0 0 0 0 0;
              0 0 0 0 1 1 0 0 0 0;
              0 0 0 1 0 0 1 0 1 0;
              0 0 0 0 0 0 0 0 0 0;
              0 0 0 0 0 0 0 1 0 1;
              0 0 0 0 0 0 0 0 0 0;
              0 0 0 0 0 0 0 0 0 0;
              0 0 0 0 0 0 0 0 0 0;
              0 0 0 0 0 0 0 0 0 0;
              0 0 0 0 0 0 0 0 0 0]
g = SimpleDiGraph(adj_matrix)
layout = Buchheim()
f, ax, p = graphplot(g, layout=layout)

Leads to the error message :

ERROR: MethodError: no method matching ne(::SimpleDiGraph{Int64})
Closest candidates are:
  ne(::Graphs.SimpleGraphs.AbstractSimpleGraph) at ~/.julia/packages/Graphs/Mih78/src/SimpleGraphs/SimpleGraphs.jl:118
  ne(::Graphs.AbstractGraph) at ~/.julia/packages/Graphs/Mih78/src/interface.jl:158
Stacktrace:
  [1] find_edge_paths(g::SimpleDiGraph{Int64}, attr::Attributes, pos::Vector{Point{2, Float32}})
    @ GraphMakie ~/.julia/packages/GraphMakie/tEQ8U/src/recipes.jl:307
  [2] (::GraphMakie.var"#19#36"{Combined{GraphMakie.graphplot, Tuple{SimpleDiGraph{Int64}}}, Observable{SimpleDiGraph{Int64}}})(pos::Vector{Point{2, Float32}}, s::MakieCore.Automatic, d::MakieCore.Automatic, w::MakieCore.Automatic)
    @ GraphMakie ~/.julia/packages/GraphMakie/tEQ8U/src/recipes.jl:162
  [3] lift(::Function, ::Observable{Any}, ::Observable{Any}, ::Vararg{Observable{Any}}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interaction/nodes.jl:13
  [4] lift(::Function, ::Observable{Any}, ::Observable{Any}, ::Observable{Any}, ::Vararg{Observable{Any}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interaction/nodes.jl:10
  [5] plot!(gp::Combined{GraphMakie.graphplot, Tuple{SimpleDiGraph{Int64}}})
    @ GraphMakie ~/.julia/packages/GraphMakie/tEQ8U/src/recipes.jl:160
  [6] plot!(scene::Scene, P::Type{Combined{GraphMakie.graphplot, Tuple{SimpleDiGraph{Int64}}}}, attributes::Attributes, input::Tuple{Observable{SimpleDiGraph{Int64}}}, args::Observable{Tuple{SimpleDiGraph{Int64}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:428
  [7] plot!(scene::Scene, P::Type{Combined{GraphMakie.graphplot}}, attributes::Attributes, args::SimpleDiGraph{Int64}; kw_attributes::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:show_axis,), Tuple{Bool}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:339
  [8] plot(P::Type{Combined{GraphMakie.graphplot}}, args::SimpleDiGraph{Int64}; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(), Tuple{}}, kw_attributes::Base.Pairs{Symbol, Buchheim{Float64, Float64}, Tuple{Symbol}, NamedTuple{(:layout,), Tuple{Buchheim{Float64, Float64}}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/figureplotting.jl:28
  [9] graphplot(args::SimpleDiGraph{Int64}; attributes::Base.Pairs{Symbol, Buchheim{Float64, Float64}, Tuple{Symbol}, NamedTuple{(:layout,), Tuple{Buchheim{Float64, Float64}}}})
    @ GraphMakie ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:31
 [10] top-level scope
    @ REPL[72]:1

Am I missing something ? I have Julia version 1.7.0. It seems to me that the package does not work for advanced versions of Julia.

This is probably due to the LightGraphs to Graphs transition. NetworkLayout supports both, newer versions of GraphMakie only Graphs. Please try with Graphs instead of LightGraphs!

1 Like