Skip to main content
`Ctrl`+`K`

# trophic_levels

trophic_levels(G, weight='weight')

  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 dict

      Dictionary of nodes with trophic level as the value.

  References

  [1]

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