density

density(B, nodes)[source]

Returns density of bipartite graph B.

Parameters
BNetworkX graph
nodes: list or container

Nodes in one node set of the bipartite graph.

Returns
dfloat

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