code: def test_trophic_levels_singular_matrix():
      """Should raise an error with graphs with only non-basal nodes"""
      matrix = np.identity(4)
      G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
      with pytest.raises(nx.NetworkXError) as e:
          nx.trophic_levels(G)
      msg = (
          "Trophic levels are only defined for graphs where every node "
          + "has a path from a basal node (basal nodes are nodes with no "
          + "incoming edges)."
      )
      assert msg in str(e.value)
  
file_path: networkx/networkx/algorithms/centrality/tests/test_trophic.py
imports: import pytest
  import networkx
label_desc: Use image node_id 6 for calling a global function with example usage: test_trophic_levels_singular_matrix() without return types