NetworkX

Previous topic

networkx.classes.function.degree_histogram

Next topic

networkx.classes.function.info

networkx.classes.function.density

networkx.classes.function.density(G)

Return the density of a graph.

The density for undirected graphs is

d = \frac{2m}{n(n-1)},

and for directed graphs is

d = \frac{m}{n(n-1)},

where n is the number of nodes and m is the number of edges in G.

Notes

The density is 0 for an graph without edges and 1.0 for a complete graph.

The density of multigraphs can be higher than 1.