Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
🐛 spectral radius returns NaN when the nertwork is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisot authored Nov 18, 2019
1 parent 6c655b5 commit 3010de6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/community/spectralradius.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end
ρ_raw(N::T, v::Float64) where {T <: UnipartiteNetwork} = v

"""
ρ(N::T; range::Bool=true) where {T <: UnipartiteNetwork}
ρ(N::T; range=EcologicalNetworks.ρ_ska) where {T <: UnipartiteNetwork}
Returns the spectral radius (the absolute value of the largest real part of the
eigenvalues of the adjacency matrix) of any unipartite network whose
Expand Down Expand Up @@ -57,6 +57,7 @@ Staniczenko, P.P.A., Kopp, J.C., Allesina, S., 2013. The ghost of nestedness in
ecological networks. Nat Commun 4, 1391. https://doi.org/10.1038/ncomms2422
"""
function ρ(N::T; range=EcologicalNetworks.ρ_ska) where {T <: UnipartiteNetwork}
links(N) == 0 && return NaN
M = mirror(N)
@assert minimum(M.A) zero(eltype(M.A))
absolute_real_part = abs.(real.(eigvals(M.A)))
Expand Down

0 comments on commit 3010de6

Please sign in to comment.