Graph density measures the fraction of possible edges that actually occur. For an undirected graph with N nodes and M edges, density is M divided by N(N−1)/2, producing a value from 0 to 1. section 4.2.3 section 10.1.3
Use density to assess how tightly connected a graph or subgraph is. Disease pathways in a protein–protein interaction network had a median density of 0.07, indicating limited internal connectivity. section 4.2.3 section 4.5
Computing pathway density
A NetworkX implementation counts nodes and edges, then calculates 2M/[N(N−1)]. For a node-level measure, construct its egonet, count observed edges, divide by N(N−1)/2, and handle egonets with fewer than two nodes.


