Skip to main content
`Ctrl`+`K`

# density

density(B, nodes)

  Returns density of bipartite graph B.

  Parameters:
    B NetworkX graph
    nodes: list or container

      Nodes in one node set of the bipartite graph.

  Returns:
    d float

      The bipartite density

  See also

  `color`

  Notes

  The container of nodes passed as argument must contain all nodes in one of the two bipartite node sets to avoid ambiguity in the case of disconnected graphs. See `bipartite documentation` for further details on how bipartite graphs are handled in NetworkX.

  Examples

      >>> from networkx.algorithms import bipartite
      >>> G = nx.complete_bipartite_graph(3, 2)
      >>> X = set([0, 1, 2])
      >>> bipartite.density(G, X)
      1.0
      >>> Y = set([3, 4])
      >>> bipartite.density(G, Y)
      1.0