Skip to content

Error for graphs with self loops #41

Closed
@mtfishman

Description

@mtfishman

Minimal example:

julia> using LightGraphs, NetworkLayout

julia> g = Graph(Edge.([1 => 2, 2 => 3]))
{3, 2} undirected simple Int64 graph

julia> Spring()(g)
3-element Vector{GeometryBasics.Point2{Float64}}:
 [-3.127142160281595, -0.30807599829163085]
 [-0.6142712514773444, -1.155509538576658]
 [1.8599722110838215, -1.9899164671852727]

julia> add_edge!(g, 1 => 1)
true

julia> Spring()(g)
ERROR: ArgumentError: Illegal buffers for SparseMatrixCSC construction 3 [1, 3, 5, 6] [1, 2, 1, 3, 2] [1, 1, 1, 1, 1, 1]
Stacktrace:
 [1] SparseMatrixCSC
   @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/SparseArrays/src/sparsematrix.jl:29 [inlined]
 [2] SparseArrays.SparseMatrixCSC(m::Int64, n::Int64, colptr::Vector{Int64}, rowval::Vector{Int64}, nzval::Vector{Int64})
   @ SparseArrays /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/SparseArrays/src/sparsematrix.jl:44
 [3] _adjacency_matrix(g::SimpleGraph{Int64}, T::DataType, neighborfn::typeof(inneighbors), nzmult::Int64)
   @ LightGraphs.LinAlg ~/.julia/packages/LightGraphs/IgJif/src/linalg/spectral.jl:63
 [4] #adjacency_matrix#2
   @ ~/.julia/packages/LightGraphs/IgJif/src/linalg/spectral.jl:25 [inlined]
 [5] adjacency_matrix (repeats 2 times)
   @ ~/.julia/packages/LightGraphs/IgJif/src/linalg/spectral.jl:20 [inlined]
 [6] layout
   @ ~/.julia/packages/NetworkLayout/TxHy6/src/NetworkLayout.jl:91 [inlined]
 [7] (::Spring{2, Float64})(adj_matrix::SimpleGraph{Int64})
   @ NetworkLayout ~/.julia/packages/NetworkLayout/TxHy6/src/NetworkLayout.jl:34
 [8] top-level scope
   @ REPL[19]:1

EDIT: This appears to be specific to Julia 1.7, see sbromberger/LightGraphs.jl#1594.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions