code: def test_random_graph(self):
      seed = 42
      G = nx.gnm_random_graph(100, 20, seed)
      G = nx.gnm_random_graph(100, 20, seed, directed=True)
      G = nx.dense_gnm_random_graph(100, 20, seed)
  
      G = nx.barabasi_albert_graph(100, 1, seed)
      G = nx.barabasi_albert_graph(100, 3, seed)
      assert G.number_of_edges() == (97 * 3)
  
      G = nx.barabasi_albert_graph(100, 3, seed, nx.complete_graph(5))
      assert G.number_of_edges() == (10 + 95 * 3)
  
      G = nx.extended_barabasi_albert_graph(100, 1, 0, 0, seed)
      assert G.number_of_edges() == 99
      G = nx.extended_barabasi_albert_graph(100, 3, 0, 0, seed)
      assert G.number_of_edges() == 97 * 3
      G = nx.extended_barabasi_albert_graph(100, 1, 0, 0.5, seed)
      assert G.number_of_edges() == 99
      G = nx.extended_barabasi_albert_graph(100, 2, 0.5, 0, seed)
      assert G.number_of_edges() > 100 * 3
      assert G.number_of_edges() < 100 * 4
  
      G = nx.extended_barabasi_albert_graph(100, 2, 0.3, 0.3, seed)
      assert G.number_of_edges() > 100 * 2
      assert G.number_of_edges() < 100 * 4
  
      G = nx.powerlaw_cluster_graph(100, 1, 1.0, seed)
      G = nx.powerlaw_cluster_graph(100, 3, 0.0, seed)
      assert G.number_of_edges() == (97 * 3)
  
      G = nx.random_regular_graph(10, 20, seed)
  
      pytest.raises(nx.NetworkXError, nx.random_regular_graph, 3, 21)
      pytest.raises(nx.NetworkXError, nx.random_regular_graph, 33, 21)
  
      constructor = [(10, 20, 0.8), (20, 40, 0.8)]
      G = nx.random_shell_graph(constructor, seed)
  
      def is_caterpillar(g):
          """
          A tree is a caterpillar iff all nodes of degree >=3 are surrounded
          by at most two nodes of degree two or greater.
          ref: http://mathworld.wolfram.com/CaterpillarGraph.html
          """
          deg_over_3 = [n for n in g if g.degree(n) >= 3]
          for n in deg_over_3:
              nbh_deg_over_2 = [
                  nbh for nbh in g.neighbors(n) if g.degree(nbh) >= 2
              ]
              if not len(nbh_deg_over_2) <= 2:
                  return False
          return True
  
      def is_lobster(g):
          """
          A tree is a lobster if it has the property that the removal of leaf
          nodes leaves a caterpillar graph (Gallian 2007)
          ref: http://mathworld.wolfram.com/LobsterGraph.html
          """
          non_leafs = [n for n in g if g.degree(n) > 1]
          return is_caterpillar(g.subgraph(non_leafs))
  
      G = nx.random_lobster(10, 0.1, 0.5, seed)
      assert max(G.degree(n) for n in G.nodes()) > 3
      assert is_lobster(G)
      pytest.raises(
          nx.NetworkXError, nx.random_lobster, 10, 0.1, 1, seed
      )
      pytest.raises(nx.NetworkXError, nx.random_lobster, 10, 1, 1, seed)
      pytest.raises(
          nx.NetworkXError, nx.random_lobster, 10, 1, 0.5, seed
      )
  
      # docstring says this should be a caterpillar
      G = nx.random_lobster(10, 0.1, 0.0, seed)
      assert is_caterpillar(G)
  
      # difficult to find seed that requires few tries
      seq = nx.random_powerlaw_tree_sequence(10, 3, seed=14, tries=1)
      G = nx.random_powerlaw_tree(10, 3, seed=14, tries=1)
  
imports: import pytest
  import networkx
label_desc: Use image node_id 1 for calling the TestGeneratorsRandom obj's underlying member method code with example usage: obj.test_random_graph() and returns: True, is_caterpillar, False