gives the graph density of the graph g.


uses rules vw to specify the graph g.

Details and Options

  • GraphDensity is the ratio of the number of edges divided by the number of edges of a complete graph with the same number of vertices.
  • A simple undirected graph with vertices and edges has graph density .
  • A simple directed graph with vertices and edges has graph density .


open allclose all

Basic Examples  (2)

Compute the density of a graph:

Graph density distribution of the Bernoulli graph model:

Scope  (6)

GraphDensity works with undirected graphs:

Directed graphs:


Mixed graphs:

Use rules to specify the graph:

GraphDensity works with large graphs:

Applications  (4)

Find the proportion of games between teams during an American college football season:

Compute the probability that two randomly chosen friends in a network are connected:

Model a social network:

Simulate the model:

Analyze the model:

The expected number of edges matches the original graph:

Distribution of density in BernoulliGraphDistribution[n,p]:

The expected value is p:

Properties & Relations  (6)

GraphDensity measures the density of the AdjacencyMatrix:

Get the density from AdjacencyMatrix:

The graph density is between 0 and 1:

The density of an empty graph is 0:

Use EmptyGraphQ to test for emptiness:

The density of a complete graph is 1:

Use CompleteGraphQ to test for complete graphs:

Converting an undirected graph to a directed graph does not change the density:

Unless self-loops are taken into consideration:

LocalClusteringCoefficient gives a local measure of density:

Introduced in 2012
Updated in 2015