# networkx.algorithms.bipartite.basic.density¶

density(B, nodes)[source]

Returns density of bipartite graph B.

Parameters
• G (NetworkX graph)

• nodes (list or container) – Nodes in one node set of the bipartite graph.

Returns

d – The bipartite density

Return type

float

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


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.