code: def test_complete_bipartite_graph(self):
      G = complete_bipartite_graph(0, 0)
      assert nx.is_isomorphic(G, nx.null_graph())
  
      for i in [1, 5]:
          G = complete_bipartite_graph(i, 0)
          assert nx.is_isomorphic(G, nx.empty_graph(i))
          G = complete_bipartite_graph(0, i)
          assert nx.is_isomorphic(G, nx.empty_graph(i))
  
      G = complete_bipartite_graph(2, 2)
      assert nx.is_isomorphic(G, nx.cycle_graph(4))
  
      G = complete_bipartite_graph(1, 5)
      assert nx.is_isomorphic(G, nx.star_graph(5))
  
      G = complete_bipartite_graph(5, 1)
      assert nx.is_isomorphic(G, nx.star_graph(5))
  
      # complete_bipartite_graph(m1,m2) is a connected graph with
      # m1+m2 nodes and  m1*m2 edges
      for m1, m2 in [(5, 11), (7, 3)]:
          G = complete_bipartite_graph(m1, m2)
          assert nx.number_of_nodes(G) == m1 + m2
          assert nx.number_of_edges(G) == m1 * m2
  
      with pytest.raises(nx.NetworkXError):
          complete_bipartite_graph(7, 3, create_using=nx.DiGraph)
      with pytest.raises(nx.NetworkXError):
          complete_bipartite_graph(7, 3, create_using=nx.MultiDiGraph)
  
      mG = complete_bipartite_graph(7, 3, create_using=nx.MultiGraph)
      assert mG.is_multigraph()
      assert sorted(mG.edges()) == sorted(G.edges())
  
      mG = complete_bipartite_graph(7, 3, create_using=nx.MultiGraph)
      assert mG.is_multigraph()
      assert sorted(mG.edges()) == sorted(G.edges())
  
      mG = complete_bipartite_graph(7, 3)  # default to Graph
      assert sorted(mG.edges()) == sorted(G.edges())
      assert not mG.is_multigraph()
      assert not mG.is_directed()
  
      # specify nodes rather than number of nodes
      for n1, n2 in [([1, 2], "ab"), (3, 2), (3, "ab"), ("ab", 3)]:
          G = complete_bipartite_graph(n1, n2)
          if isinstance(n1, numbers.Integral):
              if isinstance(n2, numbers.Integral):
                  n2 = range(n1, n1 + n2)
              n1 = range(n1)
          elif isinstance(n2, numbers.Integral):
              n2 = range(n2)
          edges = {(u, v) for u in n1 for v in n2}
          assert edges == set(G.edges)
          assert G.size() == len(edges)
  
      # raise when node sets are not distinct
      for n1, n2 in [([1, 2], 3), (3, [1, 2]), ("abc", "bcd")]:
          pytest.raises(
              nx.NetworkXError, complete_bipartite_graph, n1, n2
          )
  
file_path: networkx/networkx/algorithms/bipartite/tests/test_generators.py
imports: import numbers
  import pytest
  import networkx
  from ..generators import alternating_havel_hakimi_graph, complete_bipartite_graph, configuration_model, gnmk_random_graph, havel_hakimi_graph, preferential_attachment_graph, random_graph, reverse_havel_hakimi_graph
label_desc: Use image node_id 1 for calling the TestGeneratorsBipartite obj's underlying member method code with example usage: obj.test_complete_bipartite_graph() without return types