-
Notifications
You must be signed in to change notification settings - Fork 183
[BUG] adjacency_matrix
fails for SimpleGraph
with self-loops (Julia 1.7)
#1594
Comments
Related to JuliaGraphs/NetworkLayout.jl#41. |
Also works fine with Julia 1.6: julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) E-2176M CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = vim
(@v1.6) pkg> st LightGraphs
Status `~/.julia/environments/v1.6/Project.toml`
[093fc24a] LightGraphs v1.3.5
julia> using LightGraphs
julia> g = Graph(Edge.([1 => 2, 2 => 3]))
{3, 2} undirected simple Int64 graph
julia> adjacency_matrix(g)
3×3 SparseArrays.SparseMatrixCSC{Int64, Int64} with 4 stored entries:
⋅ 1 ⋅
1 ⋅ 1
⋅ 1 ⋅
julia> add_edge!(g, 1 => 1)
true
julia> adjacency_matrix(g)
3×3 SparseArrays.SparseMatrixCSC{Int64, Int64} with 5 stored entries:
2 1 ⋅
1 ⋅ 1
⋅ 1 ⋅ so maybe an issue with |
It looks like the error in Julia 1.7 is caused by stricter checks in the However, my guess is that it is more an issue on the |
Adding a line like: if !(T <: Bool) && !is_directed(g)
nz -= 1
end after line 57 seems to help. I think the issue is that the original definition of |
adjacency_matrix
fails for SimpleGraph
with self-loopsadjacency_matrix
fails for SimpleGraph
with self-loops (Julia 1.7)
Description of bug
adjacency_matrix
fails forSimpleGraph
with self-loops in Julia 1.7.How to reproduce
It seems to work fine for directed graphs:
The text was updated successfully, but these errors were encountered: