This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function omnivory(N::T) where {T <: UnipartiteNetwork} | ||
OI = Dict([s => 0.0 for s in species(N)]) | ||
|
||
TL = fractional_trophic_level(N) | ||
k = degree(N; dims=1) | ||
|
||
for sp_i in species(N) | ||
|
||
# Species with no interaction have an omnivory index of 0 | ||
k[sp_i] > 0 || continue | ||
|
||
# For every species, we set its initial omnivory to 0 | ||
oi = 0.0 | ||
for (j, sp_j) in enumerate(species(N)) | ||
# Then for every species it consumes, we ha | ||
tl_diff = (TL[sp_j] - (TL[sp_i]-1.0)).^2.0 | ||
corr = N[sp_i,sp_j]/k[sp_i] | ||
oi += tl_diff * corr | ||
end | ||
OI[sp_i] = oi | ||
end | ||
|
||
return OI | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters