# trophic_levels#

trophic_levels(G, weight='weight')[source]#

Compute the trophic levels of nodes.

The trophic level of a node $$i$$ is

$s_i = 1 + \frac{1}{k^{in}_i} \sum_{j} a_{ij} s_j$

where $$k^{in}_i$$ is the in-degree of i

$k^{in}_i = \sum_{j} a_{ij}$

and nodes with $$k^{in}_i = 0$$ have $$s_i = 1$$ by convention.

These are calculated using the method outlined in Levine [1].

Parameters
GDiGraph

A directed networkx graph

Returns
nodesdict

Dictionary of nodes with trophic level as the value.

References

1

Stephen Levine (1980) J. theor. Biol. 83, 195-207