networkx.algorithms.centrality.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
G (DiGraph) – A directed networkx graph
- Returns
nodes – Dictionary of nodes with trophic level as the vale.
- Return type
References
- 1
Stephen Levine (1980) J. theor. Biol. 83, 195-207