WOLFRAM

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)Summary of the most common use cases

Compute the density of a graph:

Out[1]=1

Graph density distribution of the Bernoulli graph model:

Out[2]=2

Scope  (6)Survey of the scope of standard use cases

GraphDensity works with undirected graphs:

Out[1]=1

Directed graphs:

Out[1]=1

Multigraphs:

Out[1]=1

Mixed graphs:

Out[1]=1

Use rules to specify the graph:

Out[1]=1

GraphDensity works with large graphs:

Out[2]=2

Applications  (4)Sample problems that can be solved with this function

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

Out[1]=1
Out[2]=2

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

Out[1]=1
Out[2]=2

Model a social network:

Simulate the model:

Out[3]=3

Analyze the model:

Out[4]=4

The expected number of edges matches the original graph:

Out[5]=5

Distribution of density in BernoulliGraphDistribution[n,p]:

Out[2]=2

The expected value is p:

Out[3]=3

Properties & Relations  (6)Properties of the function, and connections to other functions

GraphDensity measures the density of the AdjacencyMatrix:

Out[1]=1
Out[2]=2

Get the density from AdjacencyMatrix:

Out[3]=3
Out[4]=4

The graph density is between 0 and 1:

Out[1]=1
Out[2]=2

The density of an empty graph is 0:

Out[1]=1
Out[2]=2

Use EmptyGraphQ to test for emptiness:

Out[3]=3

The density of a complete graph is 1:

Out[1]=1
Out[2]=2

Use CompleteGraphQ to test for complete graphs:

Out[3]=3

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

Out[1]=1
Out[2]=2

Unless self-loops are taken into consideration:

Out[3]=3

LocalClusteringCoefficient gives a local measure of density:

Out[1]=1
Out[2]=2
Out[3]=3
Wolfram Research (2012), GraphDensity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDensity.html (updated 2015).
Wolfram Research (2012), GraphDensity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDensity.html (updated 2015).

Text

Wolfram Research (2012), GraphDensity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDensity.html (updated 2015).

Wolfram Research (2012), GraphDensity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDensity.html (updated 2015).

CMS

Wolfram Language. 2012. "GraphDensity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphDensity.html.

Wolfram Language. 2012. "GraphDensity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphDensity.html.

APA

Wolfram Language. (2012). GraphDensity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphDensity.html

Wolfram Language. (2012). GraphDensity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphDensity.html

BibTeX

@misc{reference.wolfram_2025_graphdensity, author="Wolfram Research", title="{GraphDensity}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphDensity.html}", note=[Accessed: 29-March-2025 ]}

@misc{reference.wolfram_2025_graphdensity, author="Wolfram Research", title="{GraphDensity}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphDensity.html}", note=[Accessed: 29-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_graphdensity, organization={Wolfram Research}, title={GraphDensity}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphDensity.html}, note=[Accessed: 29-March-2025 ]}

@online{reference.wolfram_2025_graphdensity, organization={Wolfram Research}, title={GraphDensity}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphDensity.html}, note=[Accessed: 29-March-2025 ]}