liveBook · Manning

Graph density

As explained in Graph Neural Networks in Action

Graph density is the ratio of a graph's actual edges to the total number of possible edges.

Graph density measures how many edges a graph contains relative to the total number of possible edges. For an undirected graph with n nodes, compute it as actual edges divided by n(n−1)/2. Use it during structural exploratory data analysis to judge sparsity before graph neural network training or link prediction. section 4.2.3 section 5.2.1

Interpret density alongside other graph statistics rather than treating it as a complete description:

  • A value near zero indicates that actual connections are far fewer than possible connections, so the graph is sparse. section 4.2.3 section 5.2.1
  • Compare density with average degree, connected components, clustering coefficient, and degree distribution to expose topology and possible modeling constraints. section 4.2.3 section 5.2.1
  • Check whether disconnected components change the interpretation: a dominant sparse component can determine the overall density. section 4.2.3

Fraud-network and product-network examples

A fraud graph with 45,954 nodes and 3,892,933 edges has density close to 0.00, despite an average degree of 84.71. The Amazon Electronics co-purchaser graph has 7,650 nodes and more than 143,000 edges, producing density 0.0049; both graphs are sparse, while their degree distributions reveal additional structure. section 4.2.3 section 5.2.1

How Graph Neural Networks in Action covers it

How deep it goes
Defines the edge-to-possible-edge ratio and implements its calculation, but defers rigorous derivation and broader metric theory.
Examples
Uses a fraud network near density 0.00 and an Amazon Electronics co-purchaser graph with density 0.0049.
What it assumes
Assumes adjacency data and basic graph statistics, while defining density and showing its calculation from zero.
What you can do after
Diagnose graph sparsity with NetworkX or PyTorch adjacency data and relate the result to degree and component structure.
How it connects
Ties density to graph topology, average degree, connected components, clustering coefficient, degree distribution, and link prediction.

Also explained in

Compare how 3 books explain graph density →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.