GraphDensity

GraphDensity[g]

gives the graph density of the graph g.

GraphDensity[{vw,}]

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 .

Examples

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:

Multigraphs:

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
 (9.0)
 |
Updated in 2015
 (10.3)