Return the density of a graph.
The density for undirected graphs is
and for directed graphs is
where is the number of nodes and is the number of edges in .
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.