code: def test_bipartite_density(self):
      G = nx.path_graph(5)
      X, Y = bipartite.sets(G)
      density = len(list(G.edges())) / (len(X) * len(Y))
      assert bipartite.density(G, X) == density
      D = nx.DiGraph(G.edges())
      assert bipartite.density(D, X) == density / 2.0
      assert bipartite.density(nx.Graph(), {}) == 0.0
  
file_path: networkx/networkx/algorithms/bipartite/tests/test_basic.py
imports: import pytest
  import networkx
  from networkx.algorithms import bipartite
label_desc: Use image node_id 10 for calling the TestBipartiteBasic obj's underlying member method code with example usage: obj.test_bipartite_density() without return types