From 40e5f960e2142a9572538ea26c2cc59438872dfe Mon Sep 17 00:00:00 2001 From: mtfishman Date: Tue, 19 Oct 2021 21:23:46 -0400 Subject: [PATCH] Fix bug when making an adjacency_matrix from a SimpleGraph with self-loops in Julia 1.7 --- src/linalg/spectral.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/linalg/spectral.jl b/src/linalg/spectral.jl index 80e12e075..0c61455d3 100644 --- a/src/linalg/spectral.jl +++ b/src/linalg/spectral.jl @@ -55,6 +55,9 @@ function _adjacency_matrix(g::AbstractGraph, T::DataType, neighborfn::Function, for j in 1:n_v # this is by column, not by row. if has_edge(g, j, j) push!(selfloops, j) + if !(T <: Bool) && !is_directed(g) + nz -= 1 + end end dsts = sort(neighborfn(g, j)) # TODO for most graphs it might not be necessary to sort colpt[j + 1] = colpt[j] + length(dsts)