Paths and centrality
Number of paths and shortest path
EcologicalNetworks.number_of_paths
— Functionnumber_of_paths(N::Unipartite; n::Int64=2)
This returns an array, not a network.
n
(def. 2), the path length
EcologicalNetworks.shortest_path
— Functionshortest_path(N::UnipartiteNetwork; nmax::Int64=50)
This is not an optimal algorithm at all, but it will do given that most ecological networks are relatively small. The optional nmax
argument is the longest shortest path length you will look for.
In ecological networks, the longest shortest path tends not to be very long, so any value above 10 is probably overdoing it. Note that the default value is 50, which is above 10.
shortest_path(N::UnipartiteQuantiNetwork; nmax::Int64=50)
This function will remove quantitative information, then measure the shortest path length.
EcologicalNetworks.bellman_ford
— Functionbellman_ford(N::T, source::K) where {T <: DeterministicNetwork, K}
Bellman-Ford algorithm to return the shortest / easiest paths from a source species. Refer to the bellman_ford
global documentation for the output format.
bellman_ford(N::T) where {T <: DeterministicNetwork}
Bellman-ford algorithm to return the shortest / easiest paths between all pairs of species in the networks, as long as paths exists. This function will return a tuple, with fields from
, to
and weight
. The number of elements in the tuple is the number of paths. This function works with quantitative and binary networks, and assumes that no interactions are negative.
Currently, the Bellman-Ford algorithm is slower than the shortest_path
function, but the arguments are returned in a more usable way. Note that the speed penalty is only valid when measuring the shortest paths in the entire network (and will be fixed relatively soon), and does not apply as much for the shortest paths from a single source node.
EcologicalNetworks.dijkstra
— Functiondijkstra(N::T) where {T <: DeterministicNetwork}
Dijkstra algorithm to return the shortest / easiest paths between all pairs of species in the networks, as long as paths exists. This function will return a tuple, with fields from
, to
and weight
. The number of elements in the tuple is the number of paths. This function works with quantitative and binary networks, and assumes that no interactions are negative.
dijkstra(N::T, source::K) where {T <: DeterministicNetwork, K}
Dijkstra's algorithm to return the shortest / easiest paths from a source species. Refer to the bellman_ford
global documentation for the output format.
Centrality measures
EcologicalNetworks.centrality_degree
— Functioncentrality_degree(N::UnipartiteNetwork)
Degree centrality, corrected by the maximum degree (the most central species has a degree of 1).
EcologicalNetworks.centrality_closeness
— Functioncentrality_closeness(N::UnipartiteNetwork; nmax::Int64=20)
The function calls shortest_path
internally – the nmax
argument is the maximal path length that will be tried.
References
- Bavelas, A., 1950. Communication Patterns in Task‐Oriented Groups. The Journal of the Acoustical Society of America 22, 725–730. doi:10.1121/1.1906679
EcologicalNetworks.centrality_katz
— Functioncentrality_katz(N::Unipartite; a::Float64=0.1, k::Int64=5)
This measure can work on different path length (k
), and give a different weight to every subsequent connection (a
). k
must be at least 1 (only immediate neighbors are considered). a
(being a weight), must be positive.
Katz, L., 1953. A new status index derived from sociometric analysis. Psychometrika 18, 39–43. doi:10.1007/bf02289026
EcologicalNetworks.centrality_harmonic
— Functioncentrality_harmonic(N::UnipartiteNetwork; nmax::Int64=20)
The function calls shortest_path
internally – the nmax
argument is the maximal path length that will be tried.