NotesMath for LLMs

Random Graphs

Graph Theory / Random Graphs

Notes

"In the random graph, order emerges from chaos - the giant component appears suddenly, like a phase transition in physics, when the average degree crosses one."

  • Bela Bollobas

Overview

Random graphs are probability distributions over graph-valued random variables. They provide the mathematical framework for reasoning about networks whose structure is not fully known or arises from stochastic processes - exactly the situation we face with the internet, social networks, protein interaction maps, and the implicit graphs inside neural networks.

This section develops four canonical random graph models - Erdos-Renyi G(n,p)G(n,p), Watts-Strogatz small-world, Barabasi-Albert scale-free, and the Stochastic Block Model - from their definitions through their phase transitions, spectral properties, and connections to modern machine learning. We close with graphons, the measure-theoretic limit objects that unify all dense random graph models and form the mathematical foundation of graph neural network universality theory.

The central theme is emergence: how global structure (giant components, communities, power-law degree distributions) arises from simple local rules, and how this emergence can be detected, quantified, and exploited by ML algorithms.

Prerequisites

Companion Notebooks

NotebookDescription
theory.ipynbInteractive simulations of all four models, phase transitions, spectral laws
exercises.ipynb8 graded problems from threshold functions to graphon estimation

Learning Objectives

After completing this section, you will:

  1. Define and sample from G(n,p)G(n,p), G(n,m)G(n,m), Watts-Strogatz, Barabasi-Albert, and SBM
  2. State the giant component phase transition theorem and prove the critical threshold p=1/np = 1/n
  3. Derive the Poisson degree distribution of G(n,p)G(n,p) in the sparse regime
  4. Compute clustering coefficient and average path length for small-world graphs
  5. Derive the power-law degree distribution via mean-field preferential attachment
  6. State the Kesten-Stigum threshold for community detection in the SBM
  7. Apply Wigner's semicircle law and Davis-Kahan to spectral clustering of random graphs
  8. Define graphons, the cut metric, and explain how graphons arise as limits of dense graph sequences
  9. Connect random graph theory to GNN benchmark design, graph generation, and LLM attention structure
  10. Identify and fix the most common mistakes in applying random graph models

Table of Contents


1. Intuition

1.1 What Is a Random Graph?

A random graph is not a single graph but a probability distribution over graphs. When we write GG(n,p)G \sim G(n, p), we mean: take nn labeled vertices; independently include each of the (n2)\binom{n}{2} possible edges with probability pp. The specific graph GG is a sample from this distribution.

This is a powerful abstraction. Real-world networks - social graphs, citation networks, protein-protein interaction maps, the web - cannot be written down in closed form. They arise from complex processes involving millions of actors. Random graph models capture the statistical regularity of these networks without requiring knowledge of every individual edge.

Key insight: Many properties of real-world networks can be characterized by just a few parameters (average degree, clustering coefficient, community structure), and random graph models are the mathematical objects that interpolate between these summary statistics and the full combinatorial structure of the graph.

For AI and ML, random graphs matter in at least three ways:

  1. Benchmark generation: We generate synthetic graphs from random models to test GNN algorithms across controlled conditions (the GraphWorld framework uses SBM).
  2. Graph generation models: GRAN, GDSS, and DiGress learn to sample from distributions over graphs - essentially learning a graphon.
  3. Network analysis: Training data graphs (social networks, citation networks, knowledge graphs) have structure that random graph models help characterize and exploit.

1.2 Why Random Graphs Matter for AI

The connection between random graphs and modern AI is deeper than benchmark generation:

Transformer attention is a random graph. In a language model with nn tokens and sparse attention, the attention pattern defines a random-looking bipartite graph. The connectivity of this graph determines information flow - whether distant tokens can influence each other and how quickly information propagates. Results from random graph theory (connectivity thresholds, small-world phenomena) directly predict when transformers can or cannot capture long-range dependencies.

GNN expressiveness depends on graph structure. The WL hierarchy and GIN's expressiveness guarantees depend on what graphs the model will see. If training graphs are sampled from an SBM, the GNN faces a specific community detection problem that has known information-theoretic limits - limits that bound what no GNN can achieve regardless of architecture.

Overparameterized networks are sparse graphs. The lottery ticket hypothesis says that dense networks contain sparse subnetworks (tickets) that train just as well. These sparse subnetworks have random-graph-like structure: they appear near the percolation threshold of the dense network.

Graphons = graph neural network limits. The mathematical theory of graphons (limit objects of dense graph sequences) is the same theory that gives GNNs their universality results. A GNN that is continuous in the cut metric topology of graphons is provably expressive on all graphs in the same graphon equivalence class.

1.3 The Four Canonical Models

THE FOUR CANONICAL RANDOM GRAPH MODELS
========================================================================

  Model           Parameters          Key property
  ---------------------------------------------------------------------
  Erdos-Renyi     n, p (or n, m)      Phase transition at p = 1/n
  G(n,p)          Independent edges   Poisson degree distribution
                                      Thresholds for all monotone props

  Watts-Strogatz  n, k, \beta             High clustering + short paths
  Small-World     Ring lattice +      Models social/neural networks
                  random rewiring     Navigability (Kleinberg)

  Barabasi-Albert n, m_0, m            Power-law degree distribution
  Scale-Free      Preferential        Hubs, robustness to random failure
                  attachment          Most real-world networks

  Stochastic      k, n_1,...,n_k, B     Community structure
  Block Model     Block membership    Kesten-Stigum threshold
  (SBM)           + probability matrix Benchmark for GNN node classif.

========================================================================

Each model captures one dominant feature of real-world networks:

  • ER captures mathematical tractability and threshold phenomena
  • WS captures the small-world property (short paths, high clustering)
  • BA captures heterogeneity (a few highly-connected hubs, many low-degree nodes)
  • SBM captures community structure (dense intra-community, sparse inter-community)

Real networks typically exhibit several of these properties simultaneously. Hybrid models (e.g., SBM with degree correction, or preferential attachment with community structure) better match empirical data.

1.4 Historical Timeline: 1959-2026

RANDOM GRAPH THEORY: 1959-2026
========================================================================

  1959  Erdos & Renyi introduce G(n,m); first random graph paper
  1960  Erdos & Renyi prove giant component phase transition
  1961  Erdos & Renyi prove connectivity threshold p = log(n)/n
  1984  Bollobas writes first comprehensive textbook on random graphs
  1995  Chung & Lu: random graphs with given expected degrees
  1998  Watts & Strogatz: small-world networks (Nature, ~36,000 cites)
  1999  Barabasi & Albert: scale-free networks (Science, ~50,000 cites)
  2001  Lovasz & Szegedy begin graphon theory (published 2006)
  2001  Girvan & Newman: modularity and community detection
  2007  Lovasz & Szegedy: limits of dense graph sequences (JCTB)
  2011  Mossel, Neeman, Sly: Kesten-Stigum threshold (stochastic proof)
  2014  Abbe & Sandon: exact recovery threshold for SBM
  2015  You, Ying, Leskovec: GraphRNN graph generation
  2018  Keriven & Peyre: graphon neural networks
  2020  GraphWorld: benchmark generation via SBM
  2022  Rusch, Bronstein, Mishra: gradient over-squashing theory
  2023  DiGress: discrete diffusion for graph generation
  2024  Graphon attention transformers (sparse attention limits)
  2026  Graphon-based GNN universality: completeness results

========================================================================

1.5 Phase Transitions: The Central Metaphor

The most striking feature of random graphs is the phase transition: a sudden, dramatic change in global structure as a parameter crosses a critical threshold. This is not merely a quantitative change but a qualitative one - the graph transitions from one phase (many small components) to another (one giant component plus small components).

Physical analogy: In ferromagnetism, a material transitions from disordered (many small magnetic domains) to ordered (one aligned domain) as temperature drops below the Curie point. The mathematics is identical: both are percolation phase transitions.

The critical exponent phenomenon: Near the critical point pc=1/np_c = 1/n, the giant component has size Θ(n2/3)\Theta(n^{2/3}) - a polynomial intermediate between the subcritical O(logn)O(\log n) and supercritical Θ(n)\Theta(n) regimes. This n2/3n^{2/3} scaling is a universal critical exponent that appears in many other combinatorial and physical phase transitions.

For AI: Phase transitions in random graphs correspond to phase transitions in learning. A GNN trained to detect community structure in SBMs undergoes a computational phase transition at the Kesten-Stigum threshold - above it, polynomial-time algorithms succeed; below it, no efficient algorithm can (conditional on computational hardness conjectures). This is the rigorous mathematical statement of why some graph learning problems are fundamentally hard.


2. Probability on Graphs: Formal Setup

2.1 Graph Probability Spaces

Let Gn\mathcal{G}_n denote the set of all labeled graphs on vertex set [n]={1,2,,n}[n] = \{1, 2, \ldots, n\}. A random graph model is a probability measure μ\mu on Gn\mathcal{G}_n.

Definition (Random Graph): A random graph GG on nn vertices is a random variable taking values in Gn\mathcal{G}_n, defined on some probability space (Ω,F,P)(\Omega, \mathcal{F}, \mathbb{P}).

The key examples:

G(n,p)G(n,p) (Erdos-Renyi): Each edge {u,v}([n]2)\{u,v\} \in \binom{[n]}{2} is included independently with probability pp. The probability of a specific graph gg with mm edges is:

P[G=g]=pm(1p)(n2)m\mathbb{P}[G = g] = p^m (1-p)^{\binom{n}{2} - m}

G(n,m)G(n,m) (fixed-edge): Uniform over all graphs with exactly mm edges:

P[G=g]=((n2)m)11[E(g)=m]\mathbb{P}[G = g] = \binom{\binom{n}{2}}{m}^{-1} \cdot \mathbf{1}[|E(g)| = m]

Equivalence: G(n,p)G(n,p) and G(n,m)G(n,m) with m=p(n2)m = p\binom{n}{2} have the same asymptotic behavior for most properties. More precisely, G(n,p)G(n,p) conditioned on having exactly mm edges is G(n,m)G(n,m).

Graph properties as events: A graph property P\mathcal{P} is a set of graphs closed under isomorphism (it depends only on structure, not labeling). We study the event {GP}\{G \in \mathcal{P}\} and its probability as nn \to \infty.

2.2 With High Probability (w.h.p.)

Definition (w.h.p.): We say G(n,p)G(n,p) satisfies property P\mathcal{P} with high probability (w.h.p.) if:

limnP[G(n,p)P]=1\lim_{n \to \infty} \mathbb{P}[G(n,p) \in \mathcal{P}] = 1

This is distinct from "always" - there will always be rare samples that violate the property. But in the limit, the measure of the failure set goes to zero.

Notation conventions:

  • f(n)=o(g(n))f(n) = o(g(n)): f/g0f/g \to 0
  • f(n)=ω(g(n))f(n) = \omega(g(n)): f/gf/g \to \infty
  • f(n)=Θ(g(n))f(n) = \Theta(g(n)): c1gfc2gc_1 g \le f \le c_2 g for constants c1,c2>0c_1, c_2 > 0
  • f(n)g(n)f(n) \sim g(n): f/g1f/g \to 1

Example (Isolated vertices): In G(n,p)G(n,p) with p=c/np = c/n, the probability that vertex vv is isolated is (1p)n1ec(1-p)^{n-1} \sim e^{-c}. The expected number of isolated vertices is necn \cdot e^{-c}. For c=lnnc = \ln n, this expected number is 11, and the actual number of isolated vertices is 0 w.h.p.

Markov's inequality (First Moment Method): If X0X \ge 0 and E[X]0\mathbb{E}[X] \to 0, then X=0X = 0 w.h.p. (since P[X1]E[X]0\mathbb{P}[X \ge 1] \le \mathbb{E}[X] \to 0). This proves upper bounds on the probability of properties.

Second moment method: If E[X2]/E[X]21\mathbb{E}[X^2] / \mathbb{E}[X]^2 \to 1, then X>0X > 0 w.h.p. (Paley-Zygmund inequality: P[X>0]E[X]2/E[X2]\mathbb{P}[X > 0] \ge \mathbb{E}[X]^2 / \mathbb{E}[X^2]). This proves lower bounds.

2.3 Monotone Properties and Threshold Functions

Definition (Monotone property): A graph property P\mathcal{P} is monotone increasing if whenever GPG \in \mathcal{P} and GGG' \supset G (additional edges), then GPG' \in \mathcal{P}. Examples: connectivity, containing a triangle, having a giant component.

Theorem (Bollobas-Thomason, 1987): Every non-trivial monotone graph property has a threshold function p(n)p^*(n) such that:

limnP[G(n,p)P]={0if p/p01if p/p\lim_{n \to \infty} \mathbb{P}[G(n,p) \in \mathcal{P}] = \begin{cases} 0 & \text{if } p/p^* \to 0 \\ 1 & \text{if } p/p^* \to \infty \end{cases}

The proof uses the noise sensitivity / sharp threshold theory: monotone properties exhibit sharp transitions (the window where P[P]\mathbb{P}[\mathcal{P}] goes from near-0 to near-1 is o(p)o(p^*) wide) due to the influence of edges being approximately equal.

For AI: Sharp thresholds are the theoretical explanation for why GNN performance can change dramatically as graph density or community strength crosses a critical value. A model that performs at 90% accuracy might drop to random guessing when a graph parameter decreases by a factor of 2.

2.4 First and Second Moment Methods

These are the two workhorses for proving w.h.p. statements.

First Moment (Upper Bound):

To show P\mathcal{P} holds w.h.p., find a "bad event" BB and show E[1B]0\mathbb{E}[\mathbf{1}_B] \to 0:

P[B]=E[1B]0\mathbb{P}[B] = \mathbb{E}[\mathbf{1}_B] \to 0

Second Moment (Lower Bound):

To show X>0X > 0 w.h.p. (where X=iXiX = \sum_i X_i counts copies of some structure):

Paley-Zygmund inequality: P[X>0]E[X]2E[X2]\mathbb{P}[X > 0] \ge \frac{\mathbb{E}[X]^2}{\mathbb{E}[X^2]}

Expanding: E[X2]=i,jE[XiXj]\mathbb{E}[X^2] = \sum_{i,j} \mathbb{E}[X_i X_j], so we need to bound correlations between pairs of copies.

Example (Triangles): Let XX = number of triangles in G(n,p)G(n,p).

  • E[X]=(n3)p3n3p36\mathbb{E}[X] = \binom{n}{3} p^3 \sim \frac{n^3 p^3}{6}
  • For p=c/np = c/n: E[X]c3/6\mathbb{E}[X] \sim c^3/6

The triangle threshold is p=n1p^* = n^{-1}: for p1/np \ll 1/n, no triangles w.h.p.; for p1/np \gg 1/n, triangles exist w.h.p.


3. Erdos-Renyi Model

3.1 Definitions: G(n,p) and G(n,m)

The Erdos-Renyi model is the simplest and most mathematically tractable random graph model. Its beauty lies in the complete independence of edges, which makes exact calculations feasible.

Definition G(n,p)G(n,p): The random graph on [n][n] where each edge is independently present with probability p[0,1]p \in [0,1].

Statistics:

  • E[E]=(n2)pn2p/2\mathbb{E}[|E|] = \binom{n}{2} p \approx n^2 p / 2
  • Var[E]=(n2)p(1p)\text{Var}[|E|] = \binom{n}{2} p(1-p)
  • E[deg(v)]=(n1)pnp\mathbb{E}[\deg(v)] = (n-1)p \approx np for each vertex vv

Definition G(n,m)G(n,m): The random graph on [n][n] drawn uniformly from all graphs with exactly mm edges.

Regime classification (by average degree c=(n1)pnpc = (n-1)p \approx np):

Regimepp rangecc rangeLargest component
Subcriticalp<1/np < 1/nc<1c < 1O(logn)O(\log n)
Criticalp=1/np = 1/nc=1c = 1Θ(n2/3)\Theta(n^{2/3})
Supercriticalp>1/np > 1/nc>1c > 1Θ(n)\Theta(n)
Connectedpln(n)/np \ge \ln(n)/nclnnc \ge \ln nnn (whole graph)

For AI: When analyzing message passing in sparse GNNs on ER graphs, the regime determines whether information can flow globally. Below criticality (c<1c < 1), most nodes are in isolated small components - the GNN can only see local structure. Above criticality, there's a giant component enabling global information flow.

3.2 Degree Distribution: Poisson Limit

Theorem (Poisson Degree Distribution): In G(n,p)G(n,p) with p=c/np = c/n, the degree of a fixed vertex vv satisfies:

deg(v)Binomial(n1,c/n)dPoisson(c) as n\deg(v) \sim \text{Binomial}(n-1, c/n) \xrightarrow{d} \text{Poisson}(c) \text{ as } n \to \infty

Proof sketch: deg(v)=uvXuv\deg(v) = \sum_{u \neq v} X_{uv} where XuvBernoulli(c/n)X_{uv} \sim \text{Bernoulli}(c/n) are i.i.d. The sum of n1n-1 independent Bernoullis with success probability c/nc/n converges to Poisson(cc) by the law of small numbers (Poisson limit theorem).

Generating function approach: The probability generating function of Binomial(n1,c/n)\text{Binomial}(n-1, c/n) is:

GB(z)=(1cn+czn)n1ec(z1)=GPoi(c)(z)G_{B}(z) = \left(1 - \frac{c}{n} + \frac{cz}{n}\right)^{n-1} \to e^{c(z-1)} = G_{\text{Poi}(c)}(z)

Consequences of Poisson degree distribution:

  1. Exponential tail: P[deg(v)=k]=ecck/k!\mathbb{P}[\deg(v) = k] = e^{-c} c^k / k! - degrees are concentrated near cc
  2. Max degree: maxvdeg(v)lognloglogn\max_v \deg(v) \sim \frac{\log n}{\log \log n} (sublinear in nn)
  3. No hubs: Unlike scale-free networks, ER graphs have no nodes with Ω(n)\Omega(\sqrt{n}) degree

Contrast with scale-free: Power-law degree distributions P[deg=k]kγ\mathbb{P}[\deg = k] \propto k^{-\gamma} have polynomial tails and allow hubs with degree Θ(n1/(γ1))\Theta(n^{1/(\gamma-1)}). This is why real networks (preferential attachment) look so different from ER.

3.3 Giant Component Phase Transition

This is the central theorem of random graph theory - one of the most beautiful results in all of combinatorics.

Theorem (Erdos-Renyi, 1960): Let c>0c > 0 be a constant and p=c/np = c/n. Let L1(G)L_1(G) denote the size of the largest connected component of GG(n,p)G \sim G(n,p).

  1. Subcritical (c<1c < 1): L1/lnn1/I(c)L_1 / \ln n \to 1/I(c) w.h.p., where I(c)=c1lnc>0I(c) = c - 1 - \ln c > 0. In particular, L1=O(logn)L_1 = O(\log n).

  2. Critical (c=1c = 1): L1/n2/3Θ(1)L_1 / n^{2/3} \to \Theta(1) in distribution (scaling limit is Brownian motion related).

  3. Supercritical (c>1c > 1): L1/nβ(c)L_1 / n \to \beta(c) w.h.p., where β(c)\beta(c) is the unique solution in (0,1)(0,1) to:

β=1ecβ\beta = 1 - e^{-c\beta}

The second-largest component has size O(logn)O(\log n).

The survival probability β(c)\beta(c): The equation β=1ecβ\beta = 1 - e^{-c\beta} has a probabilistic interpretation. Think of each vertex independently joining the giant component with probability β\beta. A vertex joins if it has at least one neighbor that also joins. If neighbors join with probability β\beta, and there are Poisson(c)\text{Poisson}(c) neighbors, the probability of having at least one joining neighbor is 1ecβ1 - e^{-c\beta} - hence the fixed-point equation.

Derivation via branching processes: A key technique is to compare component exploration with a branching process. Starting from vertex vv, reveal its neighbors one by one. Each neighbor independently has Poisson(c)\text{Poisson}(c) additional neighbors (in the limit). This is a Galton-Watson branching process with offspring distribution Poisson(c)\text{Poisson}(c).

A Galton-Watson process with mean offspring cc survives (generates an infinite tree) with probability β\beta satisfying β=1ecβ\beta = 1 - e^{-c\beta}. Below c=1c = 1 (mean offspring <1< 1), the process dies out almost surely - hence subcritical. Above c=1c = 1, there's a positive probability of survival - hence the giant component.

Size of the giant component:

ccβ(c)\beta(c) (fraction in giant)
0.50 (subcritical)
1.00 (critical, but n2/3n^{2/3} scaling)
1.50.583
2.00.797
3.00.940
5.00.993

For AI: GNN expressiveness on random graphs undergoes a similar phase transition. In the subcritical regime, the WL algorithm (and GINs) see disconnected local neighborhoods - they cannot distinguish non-isomorphic components. In the supercritical regime, the global component provides rich structural information.

3.4 Connectivity Threshold

Theorem (Erdos-Renyi, 1961): Let p=(lnn+c)/np = (\ln n + c) / n for a constant cRc \in \mathbb{R}. Then:

limnP[G(n,p) is connected]=eec\lim_{n \to \infty} \mathbb{P}[G(n,p) \text{ is connected}] = e^{-e^{-c}}

In particular:

  • If pln(n)/np \ll \ln(n)/n: GG is disconnected w.h.p.
  • If p=ln(n)/np = \ln(n)/n: GG is connected with probability e10.368e^{-1} \approx 0.368
  • If pln(n)/np \gg \ln(n)/n: GG is connected w.h.p.

Proof sketch (upper bound via first moment):

Let XkX_k = number of components of size kn/2k \le n/2. The bottleneck is k=1k=1 (isolated vertices). A vertex vv is isolated iff none of its n1n-1 potential edges are present:

P[v isolated]=(1p)n1=(1lnn+cn)n1e(lnn+c)=ecn\mathbb{P}[v \text{ isolated}] = (1-p)^{n-1} = \left(1 - \frac{\ln n + c}{n}\right)^{n-1} \to e^{-(\ln n + c)} = \frac{e^{-c}}{n}

Expected isolated vertices: E[X1]=necn=ec\mathbb{E}[X_1] = n \cdot \frac{e^{-c}}{n} = e^{-c}.

By a Poisson approximation argument, X1Poisson(ec)X_1 \to \text{Poisson}(e^{-c}) in distribution, so:

P[X1=0]eec\mathbb{P}[X_1 = 0] \to e^{-e^{-c}}

Connectivity fails iff X1>0X_1 > 0 or there's a larger isolated component. One shows larger components disappear before isolated vertices, so connectivity threshold == isolated vertex disappearance threshold.

Sharp threshold: The window is p=(lnn+ω(1))/np = (\ln n + \omega(1))/n - any diverging ω\omega suffices. This is an unusually sharp threshold (polynomial-width thresholds are more common).

3.5 Subgraph Counts and Triangle Thresholds

Definition: A subgraph count for a fixed graph HH is XH=X_H = number of labeled copies of HH in G(n,p)G(n,p).

Expectation:

E[XH]=n!(nV(H))!1Aut(H)pE(H)\mathbb{E}[X_H] = \frac{n!}{(n - |V(H)|)!} \cdot \frac{1}{|\text{Aut}(H)|} \cdot p^{|E(H)|}

For dense subgraphs, this simplifies to Θ(nV(H)pE(H))\Theta(n^{|V(H)|} p^{|E(H)|}).

Threshold for HH: By the first and second moment methods, XH>0X_H > 0 w.h.p. iff pn1/m(H)p \gg n^{-1/m(H)}, where:

m(H)=maxHH,V(H)1E(H)V(H)m(H) = \max_{H' \subseteq H, |V(H')| \ge 1} \frac{|E(H')|}{|V(H')|}

is the maximum 2-core density of HH.

Triangle threshold: For H=K3H = K_3 (triangle), m(H)=3/3=1m(H) = 3/3 = 1, so threshold is p=n1p^* = n^{-1}.

| Subgraph HH | V|V| | E|E| | m(H)m(H) | Threshold pp^* | |-------------|-------|-------|---------|----------------| | Edge | 2 | 1 | 1/2 | n2n^{-2} | | Path P3P_3 | 3 | 2 | 2/3 | n3/2n^{-3/2} | | Triangle K3K_3 | 3 | 3 | 1 | n1n^{-1} | | 4-clique K4K_4 | 4 | 6 | 3/2 | n2/3n^{-2/3} | | 5-clique K5K_5 | 5 | 10 | 2 | n1/2n^{-1/2} |

Janson's inequality: Provides exponential concentration for subgraph counts when E[XH]\mathbb{E}[X_H] is large:

P[XH=0]exp(E[XH]22Δ)\mathbb{P}[X_H = 0] \le \exp\left(-\frac{\mathbb{E}[X_H]^2}{2\Delta}\right)

where Δ=HHP[HHG]\Delta = \sum_{H' \sim H''} \mathbb{P}[H' \cup H'' \subseteq G] sums over pairs sharing at least one edge.

3.6 Diameter and Distances

Theorem: In G(n,p)G(n,p) with c=np>1c = np > 1 (supercritical), the diameter of the giant component is:

diamlognlog(c)\text{diam} \sim \frac{\log n}{\log(c)}

w.h.p. More precisely, diam=(1+o(1))logn/logc\text{diam} = (1 + o(1)) \log n / \log c.

Why? The giant component behaves like a random tree with branching factor cc. Starting from any node, the neighborhood of radius rr has size cr\sim c^r. It reaches nn when crnc^r \approx n, i.e., rlogn/logcr \approx \log n / \log c.

Characteristic path length: This O(logn)O(\log n) diameter is the mathematical explanation for the six degrees of separation phenomenon. With n=109n = 10^9 (Facebook) and c100c \approx 100 (100 friends), the diameter is log(109)/log(100)4.5\log(10^9) / \log(100) \approx 4.5 - indeed about 4-6 hops.

Contrast with small-world: In the ring lattice (before rewiring), diameter is n/(2k)=Ω(n)n/(2k) = \Omega(n) - linear. Watts-Strogatz introduces just β\beta fraction of random rewirings to drop this to O(logn)O(\log n) while maintaining high clustering.

3.7 Spectral Properties of G(n,p)

Expected adjacency matrix: E[A]=p(11In)\mathbb{E}[\mathbf{A}] = p(\mathbf{1}\mathbf{1}^\top - \mathbf{I}_n), a rank-1 perturbation of pI-p\mathbf{I}.

Spectral decomposition: Write A=E[A]+(AE[A])\mathbf{A} = \mathbb{E}[\mathbf{A}] + (\mathbf{A} - \mathbb{E}[\mathbf{A}]). The fluctuation matrix W=AE[A]\mathbf{W} = \mathbf{A} - \mathbb{E}[\mathbf{A}] is a Wigner matrix (symmetric, zero-diagonal, i.i.d. entries above diagonal).

Theorem (Furedi-Komlos, 1981): For G(n,p)G(n,p) with pp constant, the eigenvalues of A\mathbf{A} satisfy:

  • λ1np\lambda_1 \sim np (outlier, corresponding to the average degree direction 1/n\mathbf{1}/\sqrt{n})
  • λ2,,λn\lambda_2, \ldots, \lambda_n are in [(2+ϵ)np(1p),(2+ϵ)np(1p)][-(2+\epsilon)\sqrt{np(1-p)}, (2+\epsilon)\sqrt{np(1-p)}] w.h.p.

The bulk eigenvalues follow Wigner's semicircle law with radius 2np(1p)2\sqrt{np(1-p)}.

For spectral clustering: The spectral gap λ1λ2np2np\lambda_1 - \lambda_2 \approx np - 2\sqrt{np} determines how easily we can detect the leading eigenvector (which encodes the community structure in SBM).


4. Watts-Strogatz Small-World Model

4.1 Construction and Parameters

The Watts-Strogatz (WS) model was introduced in 1998 to explain a paradox: real-world networks (social, neural, power grid) have both high clustering AND short path lengths. Regular lattices have high clustering but long paths; ER random graphs have short paths but low clustering. WS interpolates between them.

Construction (Watts-Strogatz, 1998):

  1. Start with a ring lattice: nn nodes arranged in a circle, each connected to kk nearest neighbors (k/2k/2 on each side). Assume nklnnn \gg k \gg \ln n.
  2. Rewire: For each edge (i,j)(i, j) with j>ij > i in the ring, with probability β\beta replace jj with a uniformly random node jij' \ne i (avoiding duplicate edges).

Parameters:

  • nn: number of nodes
  • kk: initial degree (even integer, typically k{4,6,10}k \in \{4, 6, 10\})
  • β[0,1]\beta \in [0,1]: rewiring probability
    • β=0\beta = 0: regular ring lattice (high clustering, long paths)
    • β=1\beta = 1: approximately ER random graph (low clustering, short paths)
    • β0.01\beta \approx 0.01-0.10.1: small-world regime (high clustering, short paths!)

For AI: Neural network connection graphs and attention patterns often exhibit small-world structure. The feedforward layers of transformers have short path lengths (like random graphs) while local attention heads maintain clustered connections (like lattices). Understanding this structure informs efficient attention design.

4.2 Clustering Coefficient

Definition: The local clustering coefficient of vertex vv with degree dvd_v is:

Cv={(u,w)E:u,wN(v)}(dv2)C_v = \frac{|\{(u,w) \in E : u,w \in N(v)\}|}{\binom{d_v}{2}}

the fraction of vv's possible neighbor-pairs that are also connected.

Global clustering coefficient: C=1nvCvC = \frac{1}{n} \sum_v C_v (average over vertices).

Ring lattice (β=0\beta = 0): Each vertex has kk neighbors (the k/2k/2 on each side of the ring). Neighbors of vv include all nodes within distance k/2k/2. A pair of vv's neighbors (u,w)(u,w) are connected iff they are within distance k/2k/2 of each other.

For large kk, the fraction of connected neighbor pairs is approximately:

Clattice=3(k2)4(k1)34 for large kC_{\text{lattice}} = \frac{3(k-2)}{4(k-1)} \approx \frac{3}{4} \text{ for large } k

WS model: For small β\beta, the clustering coefficient is approximately:

C(β)C(0)(1β)3=3(k2)4(k1)(1β)3C(\beta) \approx C(0) \cdot (1 - \beta)^3 = \frac{3(k-2)}{4(k-1)} (1 - \beta)^3

This is because a triangle involving vv requires all three edges to survive rewiring, and each edge survives with probability (1β)(1-\beta).

Random graph (β=1\beta = 1): For ER with pk/np \approx k/n:

Crandomk/n1C_{\text{random}} \approx k/n \ll 1

Key observation: For small β\beta (say β=0.05\beta = 0.05), C(β)0.75(0.95)30.64C(\beta) \approx 0.75 \cdot (0.95)^3 \approx 0.64 - still very high, close to the lattice value.

4.3 Average Path Length

Ring lattice (β=0\beta = 0): The shortest path between two nodes separated by rr positions in the ring is r/(k/2)\lceil r / (k/2) \rceil. The average path length is approximately n/(2k)n/(2k), which grows linearly with nn.

WS model (0<β<10 < \beta < 1): The average path length drops dramatically with rewiring. Even a tiny β\beta introduces long-range shortcuts that drastically reduce path lengths.

Heuristic analysis (Newman-Watts): The typical inter-component distance after rewiring is:

L(β)nkf(nkβ/2)L(\beta) \approx \frac{n}{k} \cdot f(nk\beta/2)

where f(u)log(u)/uf(u) \sim \log(u)/u for large uu. For β2/(nk)\beta \gg 2/(nk), the path length transitions from Θ(n)\Theta(n) to Θ(logn)\Theta(\log n).

Numerical example (n=1000n = 1000, k=10k = 10):

β\betaC(β)C(\beta)L(β)L(\beta)
00.66750
0.0010.66020
0.010.6408
0.10.5285
0.50.1954
1.00.0103

The small-world regime (β0.01\beta \approx 0.01-0.050.05) achieves high CC and low LL simultaneously.

4.4 The Small-World Regime

Watts-Strogatz property: A graph is said to have the small-world property if:

  1. CCrandom=k/nC \gg C_{\text{random}} = k/n (much more clustered than ER)
  2. LLrandom=log(n)/log(k)L \approx L_{\text{random}} = \log(n)/\log(k) (path length comparable to ER)

These two conditions are simultaneously satisfied for WS with β[Ω(1/(nk)),O(1)]\beta \in [\Omega(1/(nk)), O(1)].

Empirical validation:

Watts and Strogatz validated the model against three real networks:

NetworknnkkCactualC_{\text{actual}}CrandomC_{\text{random}}LactualL_{\text{actual}}LrandomL_{\text{random}}
Film actors225,226610.790.000273.652.99
Power grid (W. US)4,9412.670.0800.00518.712.4
C. elegans neural282140.280.052.652.25

All three networks have high clustering (much above ER random graph level) but short average path lengths (comparable to ER). This is the hallmark of small-world structure.

4.5 Navigability and Kleinberg's Grid

Watts and Strogatz showed that small-world graphs have short paths, but Kleinberg (2000) asked: can nodes find these short paths using only local information?

Kleinberg's model: Start with a 2D grid of n=k×kn = k \times k nodes. Each node vv has edges to all grid neighbors within distance rr (local structure) plus one long-range link to node uu chosen with probability proportional to d(v,u)sd(v,u)^{-s}.

Theorem (Kleinberg, 2000):

  • If s=2s = 2 (exponent matches grid dimension): greedy routing finds paths of length O((logn)2)O((\log n)^2) w.h.p.
  • If s2s \ne 2: any decentralized algorithm requires Ω(nδ)\Omega(n^{\delta}) steps for some δ>0\delta > 0.

Interpretation: The power-law exponent s=ds = d (where dd is the grid dimension) uniquely enables efficient decentralized navigation. Real social networks approximate this condition, explaining how people can navigate social networks in few steps even with only local knowledge.

For AI: This connects to hierarchical attention in transformers. FlashAttention-2 and related methods achieve efficient attention by exploiting the fact that attention scores decay with token distance - a continuous analog of Kleinberg's inverse power-law long-range links.

4.6 Social Network Evidence

Small-world structure has been empirically validated across many domains:

  • Social networks: Milgram's 1967 experiment found ~6 hops between strangers in the US; Facebook (2016) found average path length 3.57 for 1.6 billion users.
  • Neural connectomes: C. elegans (302 neurons), mouse visual cortex, human brain fMRI networks all show high clustering and short paths.
  • Internet topology: ASN-level and router-level graphs exhibit small-world properties.
  • Citation networks: Academic citation graphs have C0.3C \approx 0.3-0.50.5, well above the ER baseline.

Limitations: WS does not generate power-law degree distributions. Real networks often exhibit BOTH small-world AND scale-free properties - requiring hybrid models.


5. Barabasi-Albert Scale-Free Model

5.1 Preferential Attachment

The Barabasi-Albert (BA) model was introduced in 1999 to explain a universal observation: degree distributions in real-world networks follow a power law P(k)kγP(k) \propto k^{-\gamma} with γ2\gamma \approx 2-33. This is incompatible with the exponential tails of ER's Poisson distribution.

The explanation: networks grow over time, and new nodes prefer to attach to high-degree nodes. This "rich get richer" mechanism generates hubs.

Construction (Barabasi-Albert):

  1. Start with m0mm_0 \ge m nodes with arbitrary connections.
  2. At each time step t=m0+1,m0+2,,nt = m_0+1, m_0+2, \ldots, n:
    • Add one new node vtv_t
    • Connect vtv_t to mm existing nodes, chosen independently with probability proportional to their current degree:
Π(vtu)=deg(u)wdeg(w)\Pi(v_t \to u) = \frac{\deg(u)}{\sum_{w} \deg(w)}

The denominator wdeg(w)=2E\sum_w \deg(w) = 2|E| (handshaking lemma).

Why "preferential attachment"? This mimics real-world network growth:

  • Web pages link to popular pages (already have many in-links)
  • Scientists cite highly-cited papers
  • Airports add routes to hubs

For AI: GNN training graphs from large knowledge bases (Wikidata, Freebase) exhibit scale-free degree distributions. GNN aggregation functions must handle this heterogeneity - a degree-10 node and a degree-1000 node require different treatment.

5.2 Power-Law Degree Distribution

Theorem (Barabasi-Albert, 1999; rigorous: Bollobas et al., 2001): For GBA(n,m)G \sim \text{BA}(n, m), as nn \to \infty, the degree distribution satisfies:

P[deg(v)=k]2m(m+1)k(k+1)(k+2)2m2k3 for large k\mathbb{P}[\deg(v) = k] \to \frac{2m(m+1)}{k(k+1)(k+2)} \sim \frac{2m^2}{k^3} \text{ for large } k

This is a power law with exponent γ=3\gamma = 3:

P(k)k3P(k) \propto k^{-3}

Scale-free: A distribution is called scale-free if P(k)kγP(k) \propto k^{-\gamma} for some γ>1\gamma > 1. Scale-free means the distribution looks the same at all scales (self-similar under rescaling).

Moments: For P(k)kγP(k) \propto k^{-\gamma}:

  • E[k]<\mathbb{E}[k] < \infty iff γ>2\gamma > 2
  • E[k2]<\mathbb{E}[k^2] < \infty iff γ>3\gamma > 3

For BA with γ=3\gamma = 3: mean degree is finite, but variance diverges. This has profound implications:

  • No effective epidemic threshold: diseases spread to the whole network for any transmission rate >0>0
  • Robustness to random failure: removing random nodes rarely disconnects the graph (most nodes have low degree)
  • Vulnerability to targeted attack: removing the few hubs disconnects the graph immediately

5.3 Mean-Field Analysis

Mean-field derivation: Let ki(t)k_i(t) be the degree of node ii at time tt. Treating kik_i as a continuous variable and taking expectations:

kit=mΠ(i)=mkijkj\frac{\partial k_i}{\partial t} = m \cdot \Pi(i) = m \cdot \frac{k_i}{\sum_j k_j}

Since jkj=2mt\sum_j k_j = 2mt (each new node adds mm edges, contributing 2m2m to total degree sum):

kit=ki2t\frac{\partial k_i}{\partial t} = \frac{k_i}{2t}

Solution: With initial condition ki(ti)=mk_i(t_i) = m (node ii added at time tit_i with mm initial edges):

ki(t)=mt/tik_i(t) = m \sqrt{t / t_i}

Degree distribution from mean-field: Node ii has degree >k> k at time tt iff ki(t)>kk_i(t) > k, i.e., ti<m2t/k2t_i < m^2 t / k^2. Since nodes are added uniformly at rate 1 per step:

P[ki(t)>k]=P[ti<m2t/k2]=m2t/k2t=m2k2\mathbb{P}[k_i(t) > k] = \mathbb{P}[t_i < m^2 t / k^2] = \frac{m^2 t / k^2}{t} = \frac{m^2}{k^2}

Therefore:

P(k)=ddkP[ki(t)>k]=2m2k3P(k) = -\frac{d}{dk}\mathbb{P}[k_i(t) > k] = \frac{2m^2}{k^3}

This reproduces the power law P(k)k3P(k) \propto k^{-3}, consistent with the rigorous result.

Hub formation: The oldest nodes grow fastest (degree t/ti\propto \sqrt{t/t_i}). Node ii added at time ti=1t_i = 1 has degree mn\sim m\sqrt{n} at time nn - a hub with Θ(n)\Theta(\sqrt{n}) degree.

5.4 Robustness and Fragility

Random failure: If each node is independently removed with probability qq, what is the critical qq^* above which the giant component disappears?

For a network with degree distribution P(k)P(k), the critical fraction for percolation is determined by the Molloy-Reed criterion:

E[k2]E[k]>2\frac{\mathbb{E}[k^2]}{\mathbb{E}[k]} > 2

For scale-free networks with γ3\gamma \le 3 (including BA with γ=3\gamma = 3): E[k2]=\mathbb{E}[k^2] = \infty, so this criterion always holds. No matter how many nodes are randomly removed, a giant component persists (in infinite networks). In finite BA networks, the giant component persists for qq close to 1.

Targeted attack: If the highest-degree nodes are removed first, the network is highly vulnerable. Removing even 5% of the highest-degree nodes can destroy the giant component of a BA network.

Implication for AI: Neural network pruning that removes random weights (random failure) is much safer than pruning by magnitude (targeted attack) - magnitude-based pruning could inadvertently target the "hubs" of the implicit neural network graph.

5.5 Scale-Free Networks in the Wild

Evidence for scale-free: Many networks show approximate power-law degree distributions:

  • World Wide Web: γin2.1\gamma_{\text{in}} \approx 2.1, γout2.7\gamma_{\text{out}} \approx 2.7
  • Internet (AS-level): γ2.1\gamma \approx 2.1
  • Protein-protein interaction: γ2.4\gamma \approx 2.4
  • Actor collaboration: γ2.3\gamma \approx 2.3

Controversy (2019): Broido & Clauset (2019) argued that true power laws are rare - most claimed scale-free networks fit log-normal or other heavy-tailed distributions better. The debate continues, but the practical point stands: real networks have much heavier degree tails than ER Poisson.

GNN implications: Degree-heterogeneous graphs require careful normalization in GCN-style aggregation. GraphSAGE's neighborhood sampling provides approximate uniformity; PNA (Principal Neighbourhood Aggregation) uses multiple aggregators (mean, max, std) to handle degree heterogeneity robustly.


6. Stochastic Block Model

6.1 Definition and Parameters

The Stochastic Block Model (SBM) is the canonical random graph model for community structure. It is the workhorse of GNN benchmark generation and the model for which information-theoretic limits of community detection are fully understood.

Definition (SBM): Given parameters:

  • nn: number of nodes
  • kk: number of communities/blocks
  • σ:[n][k]\sigma: [n] \to [k]: community assignment vector
  • B[0,1]k×kB \in [0,1]^{k \times k}: symmetric block probability matrix (B_{rs} = probability of edge between community rr and ss)

The SBM generates a random graph GSBM(n,k,σ,B)G \sim \text{SBM}(n, k, \sigma, B) by independently including each edge (u,v)(u,v) with probability Bσ(u),σ(v)B_{\sigma(u), \sigma(v)}.

Symmetric SBM (planted partition): All communities have equal size n/kn/k; Brr=pB_{rr} = p (within-community) and Brs=qB_{rs} = q for rsr \ne s (between-community), with p>qp > q.

Sparse SBM: p=a/np = a/n, q=b/nq = b/n with a>ba > b constants. This is the regime studied in information-theoretic limits.

Why SBM matters for AI: Node classification on real graphs (citation networks, social networks) essentially asks: given an observed graph GG with node features, recover the community labels σ\sigma. SBM provides the ground truth for studying when this is possible and what algorithms can achieve it.

6.2 Community Detection: Information-Theoretic Limits

Three regimes for symmetric 2-block SBM (k=2k = 2, equal communities):

With p=a/np = a/n, q=b/nq = b/n:

  1. Exact recovery (a>ba > b large enough): Recover σ\sigma exactly (up to global permutation) with high probability. Threshold: ab>2\sqrt{a} - \sqrt{b} > \sqrt{2}.

  2. Weak recovery / detection: Identify communities better than chance (correlated with ground truth). Threshold (Kesten-Stigum): (ab)2>2(a+b)(a-b)^2 > 2(a+b).

  3. Impossible: Below the Kesten-Stigum threshold, no algorithm can do better than random guessing.

Kesten-Stigum threshold: The SNR condition (ab)2>2(a+b)(a-b)^2 > 2(a+b) can be rewritten as:

(ab)22(a+b)>1\frac{(a-b)^2}{2(a+b)} > 1

The left side is the signal-to-noise ratio: (ab)(a-b) measures community signal, a+b\sqrt{a+b} measures noise (average degree). When SNR <1< 1, the noise overwhelms the signal.

Spectral interpretation: The second eigenvalue of the adjacency matrix satisfies λ2(ab)/nn/2=(ab)/2\lambda_2 \approx (a-b)/n \cdot n/2 = (a-b)/2. The spectral radius of the noise (Wigner semicircle) is 2(a+b)/22\sqrt{(a+b)/2}. The signal eigenvalue emerges from the noise bulk iff (ab)/2>2(a+b)/2(a-b)/2 > 2\sqrt{(a+b)/2}, i.e., (ab)2>8(a+b)/2=4(a+b)(a-b)^2 > 8(a+b)/2 = 4(a+b) - slightly different from KS due to different normalization, but same qualitative conclusion.

For GNNs: GNNs trained on SBM graphs face exactly this detection problem. Below the Kesten-Stigum threshold, no GNN - regardless of depth, width, or architecture - can reliably classify nodes into communities. This is the hard limit on what graph learning can achieve.

kk-block SBM: For kk communities, the threshold generalizes. The second eigenvalue of BB determines the computational threshold.

6.3 Degree-Corrected SBM

Real-world networks have heterogeneous degree distributions within communities. The DC-SBM adds degree parameters:

Definition (DC-SBM): Node vv has a degree parameter θv>0\theta_v > 0. The probability of edge (u,v)(u,v) is:

P[(u,v)E]=θuθvBσ(u),σ(v)\mathbb{P}[(u,v) \in E] = \theta_u \theta_v B_{\sigma(u), \sigma(v)}

Under DC-SBM, the expected degree of node vv is θvuθuBσ(v),σ(u)\theta_v \sum_u \theta_u B_{\sigma(v), \sigma(u)}. Choosing θvkα\theta_v \propto k^{-\alpha} for some power law generates a scale-free SBM combining community structure with hub-spoke topology.

Why DC-SBM matters: Citation networks and social networks have communities AND degree heterogeneity. Standard spectral clustering fails on DC-SBM because high-degree nodes dominate the leading eigenvectors. Regularized spectral clustering or normalized Laplacian-based methods are needed.

6.4 SBM as GNN Benchmark Generator

GraphWorld (2022): A Google framework that generates GNN benchmarks by sampling SBM parameters from a distribution over:

  • Number of communities k[2,20]k \in [2, 20]
  • Community sizes (balanced or Zipf-distributed)
  • Within-block density pp
  • Between-block density qq

By sampling (a,b)(a,b) pairs across and below the Kesten-Stigum threshold, GraphWorld generates benchmarks that are systematically hard or easy for GNNs.

Result: Different GNN architectures excel in different SBM regimes:

  • GCN: best for homophilic SBM (dense intra-community)
  • GraphSAGE: robust across densities
  • GIN: best near the Kesten-Stigum threshold (maximally expressive)
  • MixHop: best for heterophilic SBM (dense inter-community)

This validates the theoretical prediction that no single GNN architecture dominates all graph types.


7. Spectral Properties of Random Graphs

7.1 Wigner's Semicircle Law

Wigner's semicircle law is a fundamental result in random matrix theory that describes the bulk eigenvalue distribution of random symmetric matrices.

Setup: Let Wn=1nMnW_n = \frac{1}{\sqrt{n}} M_n where MnM_n is a real symmetric n×nn \times n random matrix with:

  • Diagonal entries Mii=0M_{ii} = 0
  • Off-diagonal entries Mij=MjiM_{ij} = M_{ji} i.i.d. with mean 0 and variance σ2\sigma^2

Theorem (Wigner, 1955): The empirical spectral distribution of WnW_n:

μn=1ni=1nδλi(Wn)\mu_n = \frac{1}{n} \sum_{i=1}^n \delta_{\lambda_i(W_n)}

converges weakly in probability to the semicircle law:

μsc(dx)=12πσ24σ2x21x2σdx\mu_{sc}(dx) = \frac{1}{2\pi\sigma^2}\sqrt{4\sigma^2 - x^2} \cdot \mathbf{1}_{|x| \le 2\sigma} dx

Support: [2σ,2σ][-2\sigma, 2\sigma] - all eigenvalues of WnW_n lie in this interval asymptotically.

For G(n,p)G(n,p): The adjacency matrix AA centered and scaled: W=(Ap11)/np(1p)W = (A - p\mathbf{1}\mathbf{1}^\top) / \sqrt{np(1-p)} has bulk eigenvalues following the semicircle law on [2,2][-2, 2] (with σ=1\sigma = 1).

The outlier eigenvalue λ1np\lambda_1 \approx np comes from the mean matrix p11p\mathbf{1}\mathbf{1}^\top - it pokes out of the bulk.

For SBM: The adjacency matrix of an SBM decomposes as A=Aˉ+WA = \bar{A} + W where Aˉ=E[A]\bar{A} = \mathbb{E}[A] is the block-structured mean matrix (rank kk) and WW is a Wigner-like noise matrix. The kk outlier eigenvalues of Aˉ\bar{A} emerge from the semicircle bulk and encode the community structure, provided the signal-to-noise ratio exceeds the Kesten-Stigum threshold.

7.2 Spectral Gap and Community Detection

Spectral algorithm for SBM:

  1. Compute the leading kk eigenvectors of AA (or normalized Laplacian LsymL_{sym})
  2. Form the n×kn \times k embedding matrix UU
  3. Run kk-means on rows of UU to recover community assignments

Why does this work? For the planted partition SBM with p=a/np = a/n and q=b/nq = b/n:

  • Leading eigenvalue: λ1(a+(k1)b)/(2k)n/n=(a+(k1)b)/2\lambda_1 \approx (a + (k-1)b)/(2k) \cdot n/n = (a + (k-1)b)/2 ... (using kk-block symmetric SBM)
  • Second eigenvalue: λ2(ab)/2\lambda_2 \approx (a-b)/2 (signal eigenvalue)
  • Bulk edge: λbulk(a+b)/2\lambda_{\text{bulk}} \approx \sqrt{(a+b)/2}

Signal eigenvalue separates from bulk iff (ab)/2>(a+b)/2|(a-b)/2| > \sqrt{(a+b)/2}, which is exactly the Kesten-Stigum condition.

Davis-Kahan bound (next subsection): If signal and noise eigenvalues are separated, the eigenvectors of AA are close to those of E[A]\mathbb{E}[A], enabling accurate community recovery.

7.3 Davis-Kahan Theorem and Perturbation Bounds

Theorem (Davis-Kahan, 1970): Let A=Aˉ+WA = \bar{A} + W where Aˉ\bar{A} is symmetric with eigenvalue λ\lambda and eigenvector u\mathbf{u}, and WW is a perturbation with Wopδ\|W\|_{op} \le \delta. Let δ\delta' be the gap between λ\lambda and all other eigenvalues of Aˉ\bar{A}. Then the corresponding eigenvector u^\hat{\mathbf{u}} of AA satisfies:

sin(u^,u)δδδ\sin\angle(\hat{\mathbf{u}}, \mathbf{u}) \le \frac{\delta}{\delta' - \delta}

Application to SBM: For the 2-block SBM:

  • Signal gap: δ=λ2(Aˉ)λ3(Aˉ)=(ab)/2\delta' = \lambda_2(\bar{A}) - \lambda_3(\bar{A}) = (a-b)/2
  • Noise: Wop2(a+b)/2(1+o(1))\|W\|_{op} \le 2\sqrt{(a+b)/2} \cdot (1 + o(1)) (Wigner semicircle radius)
  • Angle error: sin(u^2,u2)2(a+b)/2(ab)/22(a+b)/2\sin\angle(\hat{\mathbf{u}}_2, \mathbf{u}_2) \le \frac{2\sqrt{(a+b)/2}}{(a-b)/2 - 2\sqrt{(a+b)/2}}

This is o(1)o(1) iff (ab)/2>2(a+b)/2(a-b)/2 > 2\sqrt{(a+b)/2}, i.e., the Kesten-Stigum condition holds. When it holds, the estimated eigenvector is close to the ground-truth community indicator vector, and kk-means succeeds.

For GNNs: Davis-Kahan explains why GNNs with spectral-style message passing (GCN) can do community detection above the threshold but fail below it. It also shows that adding node features (which contribute additional signal to Aˉ\bar{A}) can push GNNs above the threshold even when the graph structure alone is insufficient.

7.4 Laplacian Spectrum of G(n,p)

Normalized Laplacian: Lsym=D1/2(DA)D1/2=ID1/2AD1/2L_{sym} = D^{-1/2}(D-A)D^{-1/2} = I - D^{-1/2}AD^{-1/2}.

For G(n,p)G(n,p) with pp constant:

  • Eigenvalues of LsymL_{sym} lie in [0,2][0, 2] (always)
  • λ1(Lsym)=0\lambda_1(L_{sym}) = 0 always (corresponding to 1/n\mathbf{1}/\sqrt{n})
  • For pp fixed: λn(Lsym)2\lambda_n(L_{sym}) \to 2, λ2(Lsym)1\lambda_2(L_{sym}) \to 1 - the bulk concentrates near 1

Algebraic connectivity (Fiedler value): λ2(L)\lambda_2(L) (unnormalized Laplacian) is the Fiedler value, which controls:

  • Convergence rate of random walks (mixing time 1/λ2\propto 1/\lambda_2)
  • Robustness (edge connectivity λ2\ge \lambda_2)
  • Cheeger constant approximation: λ2/2h(G)2λ2\lambda_2/2 \le h(G) \le \sqrt{2\lambda_2}

For G(n,p)G(n,p) with p=c/np = c/n, c>1c > 1: λ2(L)c2c+O(1/n)\lambda_2(L) \approx c - 2\sqrt{c} + O(1/n) for the giant component.


8. Graphons: The Infinite-Size Limit

8.1 Dense Graph Sequences and the Cut Metric

As graph size nn \to \infty, what is the "limit" of a sequence of dense graphs? This question leads to graphon theory - the measure-theoretic framework that unifies all dense random graph models.

Dense graph sequence: A sequence GnG_n of graphs with V(Gn)=n|V(G_n)| = n and E(Gn)=Θ(n2)|E(G_n)| = \Theta(n^2) (constant edge density).

Cut distance: The cut norm between two symmetric functions f,g:[0,1]2Rf, g: [0,1]^2 \to \mathbb{R} is:

fg=supS,T[0,1]S×T(f(x,y)g(x,y))dxdy\|f - g\|_{\square} = \sup_{S, T \subseteq [0,1]} \left| \int_{S \times T} (f(x,y) - g(x,y)) \, dx \, dy \right|

The cut metric between graphs GG and HH on the same vertex set is d(G,H)=WGWHd_\square(G, H) = \|W_G - W_H\|_\square where WG(x,y)W_G(x,y) is the step function encoding the adjacency of GG.

After quotienting by relabelings (graph isomorphisms), we get the cut distance δ(G,H)\delta_\square(G, H).

8.2 Graphon Definition and Sampling

Definition (Graphon): A graphon is a symmetric measurable function W:[0,1]2[0,1]W: [0,1]^2 \to [0,1].

Intuition: Think of W(x,y)W(x,y) as the "connection probability" between two abstract node types xx and yy, where node types are drawn uniformly from [0,1][0,1].

Graphon sampling: To sample an nn-node graph from graphon WW:

  1. Draw ξ1,,ξnUniform[0,1]\xi_1, \ldots, \xi_n \sim \text{Uniform}[0,1] i.i.d. (latent node types)
  2. Include edge (i,j)(i,j) with probability W(ξi,ξj)W(\xi_i, \xi_j), independently

Examples of graphons and their corresponding random graph models:

Graphon W(x,y)W(x,y)Corresponding model
W(x,y)=pW(x,y) = p (constant)Erdos-Renyi G(n,p)G(n,p)
W(x,y)=1[x+y>1]W(x,y) = \mathbf{1}[x+y > 1]Half-graph
W(x,y)=1[kx=ky]p+(11[])qW(x,y) = \mathbf{1}[\lfloor kx \rfloor = \lfloor ky \rfloor] \cdot p + (1 - \mathbf{1}[\ldots]) \cdot qkk-block SBM
W(x,y)=xyW(x,y) = x \cdot yProduct graphon (Chung-Lu style)
W(x,y)=min(x,y)W(x,y) = \min(x,y)Threshold model

Lovasz-Szegedy theorem (2006): Every convergent sequence of dense graphs (in the cut metric) converges to a graphon. Conversely, every graphon arises as the limit of a graph sequence. The space of graphons with the cut metric is compact.

For AI: Graphons are the natural limiting objects for graph neural networks. A GNN ff maps graphs to outputs. If ff is continuous in the cut metric, then f(Gn)f(W)f(G_n) \to f(W) whenever GnWG_n \to W in cut distance. This is precisely the condition for a GNN to be "robust" to graph size changes.

8.3 Homomorphism Densities and Graph Parameters

Homomorphism density: For graphs FF and GG, the homomorphism density is:

t(F,G)=hom(F,G)V(G)V(F)t(F, G) = \frac{\text{hom}(F, G)}{|V(G)|^{|V(F)|}}

where hom(F,G)\text{hom}(F, G) counts graph homomorphisms FGF \to G.

Examples:

  • t(K2,G)t(K_2, G) = edge density
  • t(K3,G)t(K_3, G) = triangle density
  • t(C4,G)t(C_4, G) = 4-cycle density

Graphon version: For a graphon WW and graph FF with kk vertices:

t(F,W)=[0,1]k(i,j)E(F)W(xi,xj)dxt(F, W) = \int_{[0,1]^k} \prod_{(i,j) \in E(F)} W(x_i, x_j) \, d\mathbf{x}

Theorem (Lovasz-Szegedy): Two graphons WW and WW' are equivalent (isomorphic in the graphon sense) iff t(F,W)=t(F,W)t(F, W) = t(F, W') for all graphs FF.

Graph parameters from homomorphism densities:

  • Triangle density: t(K3,W)=W(x,y)W(y,z)W(x,z)dxdydzt(K_3, W) = \int W(x,y)W(y,z)W(x,z) \, dx\, dy\, dz
  • Clustering coefficient: related to t(K3,W)/t(P2,W)3/2t(K_3, W) / t(P_2, W)^{3/2}

For ML: Substructure counting (homomorphism density estimation) is a key primitive for graph feature extraction. Ring GNNs and structural GNNs compute approximate homomorphism densities; this is one way to understand what graph structure GNNs learn.

8.4 Graphon Neural Networks

Definition (Graphon Neural Network, Keriven & Peyre, 2019): A graphon neural network is a sequence of functions fnf_n (on nn-node graphs) that converge to a limiting function fWf_W on graphons. Formally, fnf_n is a GNN architecture such that as GnWG_n \to W in cut metric, fn(Gn)fW(W)f_n(G_n) \to f_W(W).

Key result: GCN-style message passing with the propagation operator TWh(x)=01W(x,y)h(y)dyT_W h(x) = \int_0^1 W(x,y) h(y) \, dy defines a graphon neural network. The discrete GCN is a finite approximation.

Universality of graphon NNs: Maron et al. (2019) show that equivariant graph networks are universal approximators on graphons - any graphon property that is measurable can be approximated to arbitrary accuracy.

Limitation: Universality on graphons is density-dependent. For SPARSE graph sequences (edge density 0\to 0), graphons become trivial (the zero graphon), and a different limit theory (graphexes, local limits) is needed.

Forward reference: Graphon theory connects directly to functional analysis - the operator TWh(x)=W(x,y)h(y)dyT_W h(x) = \int W(x,y)h(y) \, dy is an integral operator on L2[0,1]L^2[0,1]. Spectral theory of compact operators (Hilbert-Schmidt theorem) governs its eigenvalue decomposition. -> Full treatment: Functional Analysis


9. Applications in Machine Learning

9.1 GraphWorld: Benchmark Generation from SBM

Problem: GNN papers often report results on 3-4 standard benchmarks (Cora, Citeseer, OGBN-Arxiv). These benchmarks may not represent the diversity of graph structures encountered in practice.

GraphWorld (Palowitch et al., 2022): A benchmark generation framework that:

  1. Parameterizes SBM space (k,n,p,q,features)(k, n, p, q, \text{features})
  2. Samples thousands of graph instances across this parameter space
  3. Evaluates GNN architectures across the full parameter landscape

Key findings:

  • No single GNN architecture dominates across all SBM parameters
  • GCN is best on homophilic dense graphs; GIN is best near the detection threshold
  • The Kesten-Stigum threshold accurately predicts when ALL GNNs fail
  • Node feature quality (signal-to-noise ratio in features) often matters more than graph structure

For practitioners: When evaluating a GNN, generate benchmarks from an SBM sweep to characterize the algorithm's operating regime, rather than relying on a few fixed benchmarks.

9.2 Graph Generation: GRAN, GDSS, DiGress

Graph generation models learn to sample new graphs from a distribution. Framed probabilistically: learn a distribution pθ(G)p_\theta(G) that matches a target distribution p(G)p^*(G).

GRAN (Graph Recurrent Attention Networks, 2019): Generates graphs node-by-node, at each step attending to previously generated nodes. The attention mechanism implicitly models preferential attachment - recently added high-degree nodes attract more attention, reproducing scale-free structure.

GDSS (Jo et al., 2022): Score-based diffusion model for graphs. Joint diffusion over node features and edge features. Samples new graphs by reversing a diffusion process that gradually adds noise. The score function implicitly learns the SBM-like block structure of training graphs.

DiGress (Vignac et al., 2022): Discrete diffusion - adds/removes edges following a Markov process. Denoising model is a graph transformer that learns to predict the original edge from the noised version. DiGress can generate molecular graphs and large social networks by learning implicit graphon structure.

Random graph theory connection: Graph generation is essentially graphon estimation. Given samples from p(G)p^*(G) (real graphs), estimate the underlying graphon WW^* such that sampling from WW^* approximates pp^*. The approximation quality is measured by the cut metric dd_\square.

9.3 LLM Attention as a Random Graph Process

Attention graph: In a transformer with LL layers and HH heads, the attention pattern at layer \ell, head hh defines a complete directed graph on tokens where edge weight (i,j)(i,j) is the attention score αij(,h)\alpha^{(\ell,h)}_{ij}.

Sparse attention = random graph: Sparse attention mechanisms (Longformer, BigBird, Reformer) explicitly sparsify the attention graph, keeping only O(n)O(n) edges rather than O(n2)O(n^2). The sparsification pattern is often random or pseudo-random.

Random graph analysis of attention:

  • Connectivity: Is the sparse attention graph connected? If not, information cannot flow between disconnected components. ER theory predicts connectivity iff expected degree lnn\ge \ln n.
  • Small-world: BigBird combines local window attention (ring lattice) with random global tokens (rewiring) and special tokens (hubs). This exactly matches the Watts-Strogatz construction!
  • Expander properties: Expander graphs (high spectral gap) are the best sparse graphs for information flow. Ramanujan graphs achieve the optimal spectral gap - this motivates expander-based sparse attention.

Result: The random graph structure of sparse attention patterns determines the theoretical expressiveness of the transformer. An attention graph that is disconnected or has large diameter cannot capture long-range dependencies regardless of the weight values.

9.4 Lottery Ticket Hypothesis and Sparse Subgraphs

Lottery Ticket Hypothesis (Frankle & Carlin, 2019): A randomly initialized dense network contains sparse subnetworks ("winning tickets") that, when trained in isolation from the same initialization, achieve comparable accuracy to the dense network.

Random graph framing: Think of the neural network as a random graph where:

  • Nodes = neurons
  • Edges = weights (including the weight value)
  • Sparsification = edge removal

The winning ticket is a sparse subgraph that retains the connectivity and flow properties of the dense graph. Random graph percolation theory describes when sparse subgraphs retain giant component connectivity.

Percolation interpretation: If we randomly retain each edge with probability ρ\rho (magnitude-based pruning approximation), the network retains its giant component iff ρ>ρc\rho > \rho_c, where ρc\rho_c is the percolation threshold. For ER-like neural network graphs, ρc1/(np0)\rho_c \approx 1/(np_0) where p0p_0 is the original edge density.

Practical implication: Networks can be pruned to 90%+ sparsity (i.e., ρ0.1\rho \approx 0.1) while retaining performance, consistent with the existence of a giant percolating subgraph at such densities for typical neural network width/depth ratios.

9.5 Social Network Analysis at Scale

Community detection at scale: For billion-node graphs (Facebook, Twitter), exact SBM community detection is computationally infeasible. In practice:

  • Louvain algorithm: Greedy modularity maximization, O(nlogn)O(n \log n)
  • Label propagation: Message-passing on the graph, converges in O(diam)O(\text{diam}) steps
  • GraphSAGE + semi-supervised: Use a few labeled nodes (community labels) to train GNN

Random graph models as null models: When analyzing a real social network, we ask: "Is the observed community structure more than what we'd expect by chance?" We compare to an ER null model with the same degree sequence (configuration model) and test whether the observed modularity exceeds the null expectation.

Link prediction: Predicting missing edges (u,v)(u,v) in a social graph using random graph models. Under ER: P[(u,v)E]=p\mathbb{P}[(u,v) \in E] = p (same for all pairs). Under SBM: P[(u,v)E]=Bσ(u),σ(v)\mathbb{P}[(u,v) \in E] = B_{\sigma(u), \sigma(v)} - within-community edges are more likely. GNNs for link prediction learn to approximate this block-structured probability.


10. Common Mistakes

#MistakeWhy It's WrongFix
1Confusing G(n,p)G(n,p) and G(n,m)G(n,m)G(n,p)G(n,p) has random edge count; G(n,m)G(n,m) has exactly mm edges - they agree asymptotically but differ in finite samplesUse G(n,p)G(n,p) when you want independence; G(n,m)G(n,m) when you want exact count control
2Assuming ER is a good null model for all real graphsER lacks clustering, hubs, and communities - major features of real networksUse configuration model (fixed degree sequence) or SBM as null model
3Saying Barabasi-Albert generates power law with any exponentBA always gives γ=3\gamma = 3; only extensions (fitness, rewiring) change γ\gammaUse generalized preferential attachment Π(v)deg(v)α\Pi(v) \propto \deg(v)^\alpha for γ=1+1/(α1)\gamma = 1 + 1/(\alpha - 1)
4Confusing clustering coefficient with transitivityLocal CC averages over vertices; global transitivity = 3×3 \times triangles / paths of length 2. They differ when degree distribution is heterogeneousUse transitivity for global property; local CC for per-node property
5Thinking the Kesten-Stigum threshold is a computational limitKS is an information-theoretic limit - it bounds what ANY algorithm can do, not just efficient ones. The computational hardness (SDP vs AMP) is a separate questionDistinguish between information-theoretic and computational thresholds
6Applying graphon theory to sparse graphsGraphons describe the limit of DENSE sequences (constant edge density). Sparse graphs (m=O(n)m = O(n)) have trivial graphon limits (the zero function)Use local weak limits (Benjamini-Schramm) or graphex theory for sparse sequences
7Equating "scale-free" with "power law"Scale-free means the DEGREE distribution is a power law. Many other distributions (log-normal, Pareto) look similar. Broido & Clauset (2019) show many claimed scale-free networks don't pass rigorous power-law testsUse maximum likelihood to fit and compare competing distributions (power law, log-normal, exponential)
8Ignoring the giant component when computing path lengthsAverage path length on a disconnected graph is undefined (infinite) or meaningless without restricting to the giant componentAlways compute path lengths within the largest connected component
9Assuming WS small-world is scale-freeWS generates Poisson-like degree distributions (each node rewires independently). It has small-world property but NOT scale-freeCombine WS with preferential attachment for small-world + scale-free
10Using the adjacency matrix spectrum directly for SBM clustering when graph is sparseFor sparse SBM, the adjacency matrix eigenvalues don't separate cleanly (semicircle radius comparable to signal). Use regularized Laplacian or Bethe-Hessian insteadReplace AA with Lrw=D1AL_{rw} = D^{-1}A or Bethe-Hessian H(ρ)=(ρ21)IρA+DH(\rho) = (\rho^2-1)I - \rho A + D
11Treating the WS model as a generative process for new nodesWS is defined on a fixed set of nn nodes with rewiring - it does not define how to add new nodes. It's not a growing network modelUse BA for growing network models; use WS for fixed-size networks
12Forgetting that graphon equivalence classes ignore node labelsTwo graphons WW and WW' are equivalent if one is a measure-preserving relabeling of the other. Most graph statistics depend only on the graphon equivalence classWork with homomorphism densities (relabeling-invariant) when comparing graphons

11. Exercises

Exercise 1 * - Phase Transition Simulation

Simulate the Erdos-Renyi phase transition computationally. For n=2000n = 2000 nodes and p=c/np = c/n with c[0.5,3.0]c \in [0.5, 3.0]:

(a) Generate G(n,p)G(n,p) for 20 values of cc linearly spaced in [0.5,3.0][0.5, 3.0].

(b) For each graph, compute the size of the largest connected component L1L_1 and the second largest L2L_2.

(c) Plot L1/nL_1/n and L2/nL_2/n as functions of cc. Identify the phase transition point visually.

(d) Overlay the theoretical prediction β(c)\beta(c) satisfying β=1ecβ\beta = 1 - e^{-c\beta}. Compute β(c)\beta(c) numerically (Newton's method or bisection) for each cc.

(e) Compute and plot L2/nL_2/n. What happens to the second-largest component at criticality? Explain from branching process theory.


Exercise 2 * - Degree Distribution Analysis

(a) Generate G(n,p)G(n,p) with n=10000n = 10000 and p=5/np = 5/n. Compute the empirical degree distribution and overlay the theoretical Poisson(5)\text{Poisson}(5) PMF.

(b) Generate a BA graph with n=10000n = 10000 and m=3m = 3. Compute the empirical degree distribution on a log-log scale and fit a power law using linear regression on the tail (k10k \ge 10). Report the estimated exponent γ^\hat{\gamma}.

(c) Compare the two distributions using a Q-Q plot. What are the key structural differences?

(d) Compute the maximum degree in each model. Derive theoretically why maxvdeg(v)=Θ(logn/loglogn)\max_v \deg(v) = \Theta(\log n / \log \log n) for ER and Θ(n)\Theta(\sqrt{n}) for BA.


Exercise 3 * - Small-World Analysis

Implement the Watts-Strogatz model from scratch.

(a) Build the ring lattice: n=500n = 500 nodes, each connected to k=10k = 10 nearest neighbors.

(b) For β{0,0.001,0.01,0.05,0.1,0.3,0.5,1.0}\beta \in \{0, 0.001, 0.01, 0.05, 0.1, 0.3, 0.5, 1.0\}, rewire each edge independently with probability β\beta. Compute C(β)C(\beta) and L(β)L(\beta) for each value.

(c) Plot normalized clustering coefficient C(β)/C(0)C(\beta)/C(0) and normalized average path length L(β)/L(0)L(\beta)/L(0) on the same plot (both on log scale for β\beta). Identify the small-world regime.

(d) Verify that C(β)C(0)(1β)3C(\beta) \approx C(0)(1-\beta)^3 for small β\beta. What does this formula say about how clustering degrades with rewiring?


Exercise 4 ** - Stochastic Block Model and Community Detection

(a) Sample an SBM with n=500n = 500, k=2k = 2 equal communities, p=a/np = a/n, q=b/nq = b/n. Use (a,b)=(20,5)(a,b) = (20, 5) (above Kesten-Stigum threshold).

(b) Apply spectral clustering: compute the second eigenvector of the adjacency matrix, threshold at 0 (positive = community 1, negative = community 2), and compute accuracy (fraction of correctly classified nodes, up to community permutation).

(c) Repeat with (a,b)=(10,5)(a,b) = (10, 5) (near threshold) and (a,b)=(6,4)(a,b) = (6, 4) (below threshold). How does accuracy vary?

(d) The Kesten-Stigum threshold for 2-block SBM is (ab)2=2(a+b)(a-b)^2 = 2(a+b). Verify your experimental results are consistent with this threshold.

(e) *** Implement the belief propagation algorithm (AMP / approximate message passing) for the 2-block SBM and compare accuracy to spectral clustering near the threshold.


Exercise 5 ** - Wigner's Semicircle Law

(a) Generate a Wigner matrix Wn=(M+M)/(2n)W_n = (M + M^\top) / (2\sqrt{n}) where MM has i.i.d. Normal(0,1)\text{Normal}(0,1) entries, for n{50,200,500,1000}n \in \{50, 200, 500, 1000\}.

(b) Plot the empirical spectral distribution (histogram of eigenvalues) for each nn. Overlay the theoretical semicircle density 2π4x2\frac{2}{\pi}\sqrt{4 - x^2} for x2|x| \le 2.

(c) Now set Wn=A/np(1p)W_n = A/\sqrt{np(1-p)} where AA is the centered adjacency matrix of G(n,p)G(n,p) with p=0.3p = 0.3, n=1000n = 1000. Plot the empirical spectral distribution. Identify the outlier eigenvalue corresponding to the average degree.

(d) For the SBM with 2 communities (n=1000n = 1000, a=15a = 15, b=3b = 3): plot the eigenvalue spectrum of AA. Identify which eigenvalues encode community structure and which are bulk noise.


Exercise 6 ** - Graphon Estimation

(a) Generate a sequence of SBM graphs with n{100,500,2000}n \in \{100, 500, 2000\}, k=3k = 3 communities, and block matrix B=(0.80.10.10.10.70.20.10.20.6)B = \begin{pmatrix} 0.8 & 0.1 & 0.1 \\ 0.1 & 0.7 & 0.2 \\ 0.1 & 0.2 & 0.6 \end{pmatrix}.

(b) For each graph, sort vertices by community label (oracle information) and display the sorted adjacency matrix as a heatmap. Does it converge to the block graphon as nn grows?

(c) Without oracle labels: apply spectral clustering to estimate community labels, then display the sorted (estimated) adjacency matrix. Measure the cut distance dd_\square between the estimated and true graphon.

(d) Implement the "histogram graphon estimator": divide [0,1]2[0,1]^2 into k2k^2 bins and estimate WW by averaging edges within each bin. Compute the L2L^2 error WestWL2\|W_{\text{est}} - W^*\|_{L^2}.


Exercise 7 *** - Giant Component Critical Window

This exercise studies the fine-grained behavior near the critical point p=1/np = 1/n.

(a) For p=(1+λn1/3)/np = (1 + \lambda n^{-1/3})/n with λ[3,3]\lambda \in [-3, 3] and n{500,2000,8000}n \in \{500, 2000, 8000\}, compute L1/n2/3L_1 / n^{2/3} for 50 trials each. Plot the distribution of L1/n2/3L_1/n^{2/3} vs λ\lambda.

(b) Observe that the distribution has a universal shape (independent of nn for large nn). This is the Brownian excursion limit - the critical window scaling is n2/3n^{2/3} for the component size and n1/3n^{1/3} for the window width.

(c) Compute the mean and standard deviation of L1/n2/3L_1 / n^{2/3} as functions of λ\lambda. Show that the mean crosses 0 near λ=0\lambda = 0 but the transition is smooth (not a jump) at finite nn.

(d) Compare to the predicted infinite-nn limit: for λ>0\lambda > 0, E[L1/n]β(1+λn1/3)λ2n1/3C\mathbb{E}[L_1/n] \to \beta(1 + \lambda n^{-1/3}) \approx \lambda^2 n^{-1/3} \cdot C for some constant CC. Verify this scaling.


Exercise 8 *** - Preferential Attachment Dynamics

(a) Implement the Barabasi-Albert preferential attachment model for n=5000n = 5000 nodes with m=2m = 2 edges per new node. Use the efficient alias method or linear scan for sampling.

(b) After generation, fit the degree distribution tail to a power law P(k)=CkγP(k) = C k^{-\gamma} using maximum likelihood estimation on kkmink \ge k_{\min} for suitable kmink_{\min}.

(c) Track the degree of each node over time as the network grows. Plot ki(t)k_i(t) for nodes added at times ti{10,100,500,1000}t_i \in \{10, 100, 500, 1000\}. Verify the mean-field prediction ki(t)mt/tik_i(t) \approx m\sqrt{t/t_i}.

(d) Implement "fitness-based" preferential attachment: Π(v)ηvdeg(v)\Pi(v) \propto \eta_v \deg(v) where ηvUniform[0,1]\eta_v \sim \text{Uniform}[0,1] is a fixed fitness. Compare the resulting degree distribution to standard BA. Does the power-law exponent change?

(e) Simulate a targeted attack: iteratively remove the highest-degree node. Plot the size of the giant component as a function of fraction of nodes removed. Compare to random removal. What fraction of nodes must be targeted to destroy the giant component?


12. Why This Matters for AI (2026 Perspective)

ConceptImpact on AI/ML
ER Phase TransitionConnectivity threshold determines information flow in GNNs on sparse graphs; GCN cannot aggregate across disconnected components, giving a hard limit on performance
Poisson Degree DistributionMost GNN benchmark graphs (Cora, Citeseer) have near-Poisson degrees; GCN's symmetric normalization is optimal for Poisson-degree graphs but suboptimal for scale-free
Kesten-Stigum ThresholdHard information-theoretic limit on community detection; no GNN can exceed this on SBM data regardless of architecture, depth, or width
Scale-Free NetworksReal knowledge graphs (Wikidata, Freebase) are scale-free; hub nodes with Θ(n)\Theta(\sqrt{n}) degree dominate GCN aggregation - require degree-aware normalization or degree-bucketing
Small-World StructureTransformer attention graphs have small-world properties; BigBird/Longformer mimic WS construction (local window + random long-range); designing optimal sparse attention = finding optimal WS parameters
GraphonsTheoretical foundation for GNN universality; GNNs that are continuous in cut metric topology can generalize across graph sizes; graphon theory predicts which graph properties a GNN can and cannot learn
Graphon Neural NetworksFirst provably universal GNN framework; used to prove that message-passing GNNs cannot distinguish non-isomorphic graphs with identical WL certificates
Spectral GapControls convergence rate of GNN over-smoothing (energy decays at rate λ2\lambda_2); higher Fiedler value -> faster smoothing -> shallower optimal depth
Davis-KahanExplains why spectral GNNs (GCN) succeed above community detection threshold and fail below; same theorem underlies learning theory for graph classification
Wigner SemicircleBulk eigenvalue distribution of noise in graph learning; signal from community structure must exceed semicircle radius to be learnable - same condition as Kesten-Stigum
Configuration ModelNull model for testing GNN hypotheses: does the GNN learn graph structure, or just degree sequence? Test by evaluating on configuration model graphs with same degree sequence
Random Graph GenerationDiGress, GDSS, GRAN all learn distributions over graphs - effectively learning graphons. Quality measured by cut distance between learned and true graphon

13. Conceptual Bridge

Backward: What This Builds On

Random graph theory synthesizes several branches of mathematics developed in earlier sections:

From Spectral Graph Theory (04): The Laplacian eigenvalues λ2,,λn\lambda_2, \ldots, \lambda_n studied there take on probabilistic meaning here - for random graphs, they become random variables following the Wigner semicircle law. The spectral gap λ2\lambda_2 that controls mixing time in deterministic graphs now becomes a random quantity whose distribution determines community detectability.

From Probability Theory (07-Probability-Statistics): All threshold results (giant component, connectivity, community detection) use first and second moment methods, Chernoff bounds, and the Poisson limit theorem. Branching process theory is the probabilistic tool that gives the exact threshold equation β=1ecβ\beta = 1 - e^{-c\beta}.

From Graph Neural Networks (05): The SBM community detection problem IS the node classification problem that GNNs solve in practice. The Kesten-Stigum threshold gives the hard limit on what any GNN can achieve, while Davis-Kahan shows why spectral GNNs succeed above this threshold.

Forward: What This Enables

Functional Analysis (12): The graphon operator TWh(x)=01W(x,y)h(y)dyT_W h(x) = \int_0^1 W(x,y)h(y)\,dy is a Hilbert-Schmidt operator on L2[0,1]L^2[0,1]. Its spectral theory - the Hilbert-Schmidt theorem giving a countable orthonormal eigenfunction expansion - is the infinite-dimensional generalization of the adjacency matrix eigendecomposition. This is the full treatment of graphon operators.

Graph Algorithms (07): Random graph models motivate efficient algorithms: spectral clustering (from SBM theory), Louvain community detection (from modularity theory), and link prediction (from random graph null models). The average-case complexity of graph problems is analyzed using random graph models.

Information Theory (09): The Kesten-Stigum threshold is an information-theoretic limit - it follows from a channel capacity argument. The mutual information between the community labels σ\sigma and the observed graph GG is zero below the threshold, making recovery impossible regardless of computation. This connects random graphs to channel coding theory.

POSITION IN CURRICULUM
========================================================================

  04 Spectral Graph Theory
       |  Laplacians, eigenvalues, Cheeger inequality
       |
       +--> 05 Graph Neural Networks
       |         GCN, GAT, GIN, MPNN, expressiveness
       |
       +--> 06 Random Graphs  <=== YOU ARE HERE
                |
                +- Erdos-Renyi: phase transitions, thresholds
                +- Watts-Strogatz: small-world, navigation
                +- Barabasi-Albert: scale-free, preferential attachment
                +- SBM: communities, Kesten-Stigum threshold
                +- Spectral theory: semicircle law, Davis-Kahan
                +- Graphons: infinite limits, universality
                       |
                       v
                07 Graph Algorithms
                       |
                       v
                12 Functional Analysis <-- graphon operators T_W
                       Hilbert-Schmidt theory, L^2 spectral decomposition

========================================================================

The central insight of this section - that random graph models are not merely toy examples but rigorous frameworks for understanding real network behavior - carries forward into every domain where graphs appear. In machine learning, understanding when community structure is detectable, when information can flow across a sparse graph, and when a graph distribution can be learned from samples are fundamental questions with precise mathematical answers, and those answers come from random graph theory.


<- Back to Graph Theory | Next: Graph Algorithms ->


Appendix A: Branching Process Theory

A.1 Galton-Watson Branching Processes

A Galton-Watson process is a model of population growth where each individual independently produces offspring according to a fixed offspring distribution {pk}k0\{p_k\}_{k \ge 0}.

Formal definition: Let Z0=1Z_0 = 1 (a single ancestor). At generation tt, if Zt=zZ_t = z, each of the zz individuals produces offspring independently according to {pk}\{p_k\}:

Zt+1=i=1Ztξi(t)Z_{t+1} = \sum_{i=1}^{Z_t} \xi_i^{(t)}

where ξi(t){pk}\xi_i^{(t)} \sim \{p_k\} i.i.d.

Mean offspring: μ=kkpk=E[ξ]\mu = \sum_k k p_k = \mathbb{E}[\xi].

Probability generating function (PGF): ϕ(s)=kpksk=E[sξ]\phi(s) = \sum_k p_k s^k = \mathbb{E}[s^\xi].

Extinction probability: The probability of ultimate extinction q=limtP[Zt=0]q = \lim_{t \to \infty} \mathbb{P}[Z_t = 0] satisfies q=ϕ(q)q = \phi(q).

Theorem (Extinction):

  • If μ1\mu \le 1: q=1q = 1 (certain extinction)
  • If μ>1\mu > 1: q<1q < 1 (positive survival probability =1q= 1 - q)

Connection to ER: For G(n,p)G(n,p) with p=c/np = c/n, exploring the component of a vertex proceeds like a branching process where each node has Binomial(nk,c/n)Poisson(c)\text{Binomial}(n-k, c/n) \approx \text{Poisson}(c) offspring (unexplored neighbors). The giant component probability β\beta satisfies:

1β=q=ecβ=ϕPoisson(c)(1β)1 - \beta = q = e^{-c\beta} = \phi_{\text{Poisson}(c)}(1 - \beta)

exactly the fixed-point equation β=1ecβ\beta = 1 - e^{-c\beta}.

A.2 Multi-Type Branching Processes

For the SBM with kk communities, the local neighborhood exploration is a multi-type branching process where the type of an individual is its community label.

Offspring matrix: MrsM_{rs} = expected number of type-ss offspring from a type-rr parent.

For the symmetric 2-block SBM with p=a/np = a/n, q=b/nq = b/n:

M=12(abba)M = \frac{1}{2}\begin{pmatrix} a & b \\ b & a \end{pmatrix}

Survival theorem: The multi-type branching process survives iff ρ(M)>1\rho(M) > 1, where ρ(M)\rho(M) is the spectral radius.

Eigenvalues of MM: λ+=(a+b)/2\lambda_+ = (a+b)/2, λ=(ab)/2\lambda_- = (a-b)/2.

  • Giant component exists iff λ+>1\lambda_+ > 1, i.e., a+b>2a + b > 2 (average degree condition).
  • Community detection possible iff the "community eigenvalue" λ=(ab)/2>1\lambda_- = (a-b)/2 > 1 ... but this is not quite right. The actual condition involves the non-backtracking matrix.

Non-backtracking operator: The correct spectral condition for SBM community detection uses the non-backtracking (Hashimoto) operator BB on directed edges. The eigenvalue of BB corresponding to community structure is (ab)/2(a-b)/2, and the bulk spectral radius is (a+b)/2\sqrt{(a+b)/2}. Community detection is possible iff:

ab2>a+b2\frac{a-b}{2} > \sqrt{\frac{a+b}{2}}

i.e., (ab)2>2(a+b)(a-b)^2 > 2(a+b) - precisely the Kesten-Stigum threshold.

A.3 Critical Branching Processes

At criticality μ=1\mu = 1 (Poisson offspring with c=1c = 1), the branching process has a different behavior:

Yaglom's theorem: Conditioned on survival to generation tt, the population Zt/tZ_t / t converges in distribution to an Exponential(1) random variable:

P[Zt/t>xZt>0]ex\mathbb{P}[Z_t / t > x \mid Z_t > 0] \to e^{-x}

For the ER critical window: At p=1/np = 1/n, the largest component has size Θ(n2/3)\Theta(n^{2/3}) and there are Θ(n1/3)\Theta(n^{1/3}) such components. The component size distribution follows Yaglom's theorem for the critical Poisson branching process, but rescaled by n2/3n^{2/3}.


Appendix B: Configuration Model

B.1 Definition

The configuration model generates a random graph with a prescribed degree sequence (d1,d2,,dn)(d_1, d_2, \ldots, d_n).

Construction:

  1. Give vertex vv exactly dvd_v "half-edges" (stubs)
  2. Pair up all 2m=vdv2m = \sum_v d_v half-edges uniformly at random
  3. Each pairing creates an edge

Result: A random multigraph (may have self-loops and multi-edges) with the given degree sequence.

Properties:

  • For degree sequences with bounded maximum degree: the number of self-loops and multi-edges is O(1)O(1) - a simple graph w.h.p.
  • Conditioned on simplicity: uniform over all simple graphs with the given degree sequence

Why use it? The configuration model is the correct null model for testing graph hypotheses. Instead of comparing to ER (wrong degree distribution), compare to configuration model (same degree distribution, no other structure). If a property (e.g., high clustering) exceeds what configuration model predicts, it's genuinely structural, not just a degree artifact.

B.2 Giant Component in Configuration Model

For the configuration model with degree distribution P(k)P(k):

Molloy-Reed criterion: A giant component exists iff:

kk(k2)P(k)>0    E[k2]E[k]>2\sum_k k(k-2) P(k) > 0 \iff \frac{\mathbb{E}[k^2]}{\mathbb{E}[k]} > 2

Interpretation: The excess degree distribution qk=(k+1)P(k+1)/E[k]q_k = (k+1)P(k+1)/\mathbb{E}[k] governs the branching factor of the exploration process. The process is supercritical (giant component exists) iff the mean of qkq_k exceeds 1, which is E[k(k1)]/E[k]>1\mathbb{E}[k(k-1)]/\mathbb{E}[k] > 1.

For scale-free networks: With P(k)kγP(k) \propto k^{-\gamma}, E[k2]\mathbb{E}[k^2] diverges when γ3\gamma \le 3. Hence the Molloy-Reed criterion is always satisfied for BA-style scale-free networks - a giant component exists for arbitrarily sparse scale-free graphs.

For ER: P(k)=ecck/k!P(k) = e^{-c} c^k / k! (Poisson), so E[k2]=c2+c\mathbb{E}[k^2] = c^2 + c and E[k]=c\mathbb{E}[k] = c. Molloy-Reed: (c2+c)/c>2c+1>2c>1(c^2 + c)/c > 2 \Leftrightarrow c + 1 > 2 \Leftrightarrow c > 1 - exactly the ER threshold.

B.3 Clustering in Configuration Model

For the configuration model:

Cconf=(E[k2]E[k])2nE[k]30C_{\text{conf}} = \frac{(\mathbb{E}[k^2] - \mathbb{E}[k])^2}{n \cdot \mathbb{E}[k]^3} \to 0

as nn \to \infty (for fixed degree distribution). The configuration model has vanishing clustering coefficient - it's locally tree-like.

Real networks vs. configuration model: Comparing observed clustering to Cconf0C_{\text{conf}} \approx 0 tests for genuine clustering beyond degree effects. Small-world networks have CCconfC \gg C_{\text{conf}} - they have clustering not explained by degree distribution alone.


Appendix C: Percolation Theory

C.1 Bond Percolation on Graphs

Bond percolation: Given a graph GG and probability ρ[0,1]\rho \in [0,1], independently retain each edge with probability ρ\rho. Let GρG_\rho denote the resulting random subgraph.

Site percolation: Independently retain each vertex with probability ρ\rho.

Critical probability: The percolation threshold ρc\rho_c is the infimum of ρ\rho for which GρG_\rho has an infinite component (on infinite graphs) or a giant component of size Θ(n)\Theta(n) (on finite graphs).

On the integer lattice Zd\mathbb{Z}^d: Exact thresholds:

  • d=1d = 1: ρc=1\rho_c = 1 (must keep all edges)
  • d=2d = 2 (square lattice): ρc=1/2\rho_c = 1/2 exactly (by self-duality)
  • d2d \ge 2: ρc<1\rho_c < 1; harder to compute exactly

On ER graphs: Bond percolation on G(n,p0)G(n,p_0) with retention probability ρ\rho gives G(n,ρp0)G(n, \rho p_0). The percolation threshold is ρc=1/(np0)\rho_c = 1/(np_0), so the giant component survives iff ρ>1/(np0)\rho > 1/(np_0), i.e., ρnp0>1\rho np_0 > 1.

C.2 Connection to Neural Network Pruning

Neural network weight pruning is isomorphic to bond percolation:

  • Dense network graph GG (neurons = nodes, weights = edges)
  • Pruning mask mij{0,1}m_{ij} \in \{0,1\} with P[mij=1]=ρ\mathbb{P}[m_{ij} = 1] = \rho (retention probability)
  • Pruned network GρG_\rho must retain computational connectivity

For the network to maintain its computational capacity, it must retain a giant component. The percolation threshold ρc\rho_c gives the minimum retention rate.

Structured pruning: Head pruning in transformers (removing entire attention heads) is site percolation on the attention head graph. Magnitude pruning selects edges by weight magnitude - approximately bond percolation with ρ=\rho = fraction of weights retained.

Lottery ticket connection: A winning lottery ticket is precisely a giant percolating subgraph that retains the "signal paths" of the original network. The existence of such subgraphs at high sparsity (ρ0.1\rho \approx 0.1) is guaranteed by percolation theory for sufficiently wide networks.

C.3 Expanders and Optimal Percolation

Expander graph: A dd-regular graph GG on nn nodes with spectral gap λ(G)=dλ2(AG)\lambda(G) = d - \lambda_2(A_G). Large spectral gap means fast mixing and high robustness.

Percolation on expanders: For a dd-regular expander, the percolation threshold is ρc=1/(dλ(G)/d)11/(d1)\rho_c = 1/(d - \lambda(G)/d)^{-1} \approx 1/(d - 1) for bounded-degree expanders. The giant component after percolation at ρ>ρc\rho > \rho_c has size (1ϵ)n\ge (1 - \epsilon)n for small ϵ\epsilon.

Implication for sparse attention: Expander-based sparse attention (using Ramanujan graphs with spectral gap d2d1\approx d - 2\sqrt{d-1}) achieves:

  • O(n)O(n) edges (efficient)
  • O(logn)O(\log n) diameter (short paths)
  • Maximum spectral gap (optimal information flow)
  • Robust to random edge removal (good percolation threshold)

This is why expanders are theoretically optimal sparse attention patterns, even if not used in practice due to implementation complexity.


Appendix D: Threshold Functions - Complete Table

Property P\mathcal{P}Threshold p(n)p^*(n)Window widthNotes
Contains an edgen2n^{-2}Θ(p)\Theta(p^*)First property to appear
Contains a trianglen1n^{-1}Θ(p)\Theta(p^*)K3K_3 threshold
Contains K4K_4n2/3n^{-2/3}Θ(p)\Theta(p^*)m(K4)=3/2m(K_4) = 3/2
Contains KrK_rn2/(r1)n^{-2/(r-1)}Θ(p)\Theta(p^*)m(Kr)=(r1)/2m(K_r) = (r-1)/2
Giant component1/n1/nΘ(1/(n))\Theta(1/(n))Phase transition
Connectivityln(n)/n\ln(n)/n1/n1/n (sharp!)Very sharp threshold
Diameter 2\le 2ln(n)/n\sqrt{\ln(n)/n}Θ(p)\Theta(p^*)
Contains Hamiltonian cycleln(n)/n\ln(n)/n1/n1/nSame as connectivity!
Planarity loss1/n1/nΘ(1/n)\Theta(1/n)Planarity threshold
Chromatic number >k> kProblem-dependentVariesOpen for exact kk

Sharp vs. coarse thresholds:

A threshold p(n)p^*(n) is sharp if the transition from probability 0 to probability 1 occurs in a window of width o(p)o(p^*). Connectivity and Hamiltonian cycles have sharp thresholds (window width O(1/n)ln(n)/nO(1/n) \ll \ln(n)/n).

A threshold is coarse if the window is Θ(p)\Theta(p^*). Most subgraph appearance thresholds are coarse - the probability transitions from ϵ\epsilon to 1ϵ1-\epsilon over a multiplicative constant change in pp.

Friedgut's theorem (1999): Every monotone property has a sharp threshold OR can be reduced to a "small" property. Most natural properties (connectivity, kk-colorability) have sharp thresholds. This is the technical statement of the Bollobas-Thomason heuristic.


Appendix E: Random Geometric Graphs

E.1 Definition

A random geometric graph G(n,r)G(n, r) is constructed by:

  1. Placing nn nodes uniformly at random in [0,1]2[0,1]^2 (or another metric space)
  2. Connecting two nodes iff their Euclidean distance is r\le r

Properties:

  • Soft threshold for connectivity: r=lnn/(πn)r^* = \sqrt{\ln n / (\pi n)} - same lnn/n\ln n / n scaling as ER
  • High clustering: Nodes close to each other share many common neighbors (geometric constraint) - C1C \to 1 as r0r \to 0 with nr2nr^2 fixed
  • Bounded degree distribution: All degrees in [0,πnr2][0, \pi n r^2]
  • No long-range edges: Maximum edge length =r= r, giving large diameter for small rr

For AI: Random geometric graphs model sensor networks, robotic swarms, and spatial point processes. They also model attention in vision transformers where tokens correspond to image patches at geometric positions - nearby patches should have high attention, distant patches low.

E.2 Comparison to Other Models

PropertyERWSBAGeometric
Degree dist.PoissonPoisson-likePower lawBounded
ClusteringLowHighLowVery high
Path lengthO(logn)O(\log n)O(logn)O(\log n)O(logn/loglogn)O(\log n / \log \log n)O(1/r)O(1/r)
SpatialNoNoNoYes
Community struct.NoneNoneNoneImplicit (spatial)

E.3 Connection to Kernel Methods

The random geometric graph adjacency matrix is a kernel matrix:

Aij=1[xixj2r]=k(xi,xj)A_{ij} = \mathbf{1}[\|x_i - x_j\|_2 \le r] = k(x_i, x_j)

with kernel k(x,y)=1[xyr]k(x,y) = \mathbf{1}[\|x-y\| \le r] (indicator kernel).

More generally, kernel random graphs use AijBernoulli(k(xi,xj))A_{ij} \sim \text{Bernoulli}(k(x_i, x_j)) for a kernel function k:X2[0,1]k: \mathcal{X}^2 \to [0,1]. This is a graphon with W(x,y)=k(x,y)W(x,y) = k(x,y) for node types x,yXx,y \in \mathcal{X}.

For attention: The softmax attention matrix softmax(QK/d)\text{softmax}(QK^\top/\sqrt{d}) is a random kernel matrix where the "positions" are query/key vectors. Random graph theory for kernel random graphs directly applies to study information flow in attention layers.


Appendix F: Network Motifs and Subgraph Statistics

F.1 Network Motifs

Definition: A network motif is a subgraph pattern that occurs significantly more often in a real network than in random graphs with the same degree sequence (configuration model null).

Common motifs:

  • Feedforward loop (3-node DAG): overrepresented in gene regulatory networks
  • Bifan (2->2->2 bipartite): common in neural circuits
  • Clique (K3K_3, K4K_4): overrepresented in social networks

Detection: For each candidate subgraph HH, compare t(H,Greal)t(H, G_{\text{real}}) (density in real graph) to E[t(H,Gconfig)]\mathbb{E}[t(H, G_{\text{config}})] (expected density under null model). Z-score >2> 2: motif. Z-score <2< -2: anti-motif.

For GNNs: Motif counting is a proxy for what GNNs learn. Standard MPNNs (GCN, GraphSAGE) can count triangles but not 4-cycles. Higher-order GNNs (OSAN, subgraph GNNs) can count richer motif sets. The motif profile of a graph determines which GNN architecture is most suitable.

F.2 Triangle Counting at Scale

Exact triangle count: For dense graphs, T=16tr(A3)T = \frac{1}{6}\text{tr}(A^3) using matrix multiplication in O(n2.37)O(n^{2.37}) (matrix multiplication exponent). For sparse graphs (m=O(n)m = O(n)), algorithms run in O(m3/2)O(m^{3/2}).

Approximate counting: For massive graphs (n=109n = 10^9), use streaming algorithms or random sampling:

  • Wedge sampling: Count triangles by sampling paths of length 2 and checking closure
  • DOULION: Sample edges independently with probability ρ\rho; count triangles in subgraph; scale by 1/ρ31/\rho^3

Expected triangle count in G(n,p)G(n,p): E[T]=(n3)p3n3p3/6\mathbb{E}[T] = \binom{n}{3} p^3 \approx n^3 p^3 / 6.

Concentration: For np3n2np^3 n^2 \to \infty, by Azuma-Hoeffding (Lipschitz condition), TT concentrates around its mean with standard deviation O(mean/n)O(\text{mean}/\sqrt{n}).


Appendix G: Information-Theoretic Limits

G.1 Mutual Information and Detection

The detection problem: Given GSBM(n,2,σ,p,q)G \sim \text{SBM}(n, 2, \sigma, p, q), recover σ\sigma (up to global flip).

Impossible regime: Below the Kesten-Stigum threshold, the mutual information I(σ;G)=0I(\sigma; G) = 0 in the nn \to \infty limit. This means the graph GG contains literally no information about the community labels that could be extracted by any algorithm.

Formal statement: For p=a/np = a/n, q=b/nq = b/n, (ab)22(a+b)(a-b)^2 \le 2(a+b):

limnI(σ;G)/n=0\lim_{n \to \infty} I(\sigma; G) / n = 0

The /n/ n normalization is because both σ\sigma and GG grow with nn; the mutual information per node goes to 0.

Above threshold: For (ab)2>2(a+b)(a-b)^2 > 2(a+b):

limnI(σ;G)/n=hb(1+α2)hb(12)>0\lim_{n \to \infty} I(\sigma; G) / n = h_b\left(\frac{1+\alpha^*}{2}\right) - h_b\left(\frac{1}{2}\right) > 0

where α\alpha^* is the Bayes-optimal overlap and hbh_b is binary entropy.

G.2 Exact Recovery Threshold

For the exact recovery problem (recover σ\sigma exactly, not just correlate with it), the threshold is higher:

Theorem (Abbe-Sandon, 2015): For the 2-block SBM with p=aln(n)/np = a \ln(n)/n, q=bln(n)/nq = b \ln(n)/n:

Exact recovery is possible w.h.p.    (ab)2>2\text{Exact recovery is possible w.h.p.} \iff \left(\sqrt{a} - \sqrt{b}\right)^2 > 2

This is the CHI-squared divergence condition between the Poisson distributions with means aa and bb.

The three thresholds:

  1. Impossible: (ab)22(a+b)(a-b)^2 \le 2(a+b) - no algorithm can detect communities
  2. Weak recovery: (ab)2>2(a+b)(a-b)^2 > 2(a+b) - algorithms exist to partially recover
  3. Exact recovery: (ab)2>2(\sqrt{a} - \sqrt{b})^2 > 2 - algorithms exist for exact recovery

These thresholds become relevant for GNN practitioners when designing tasks: is the community detection problem in your benchmark achievable at all? Which threshold regime does it fall in?


Appendix H: Practical Algorithms

H.1 Spectral Clustering Pipeline for SBM

INPUT: Adjacency matrix A of SBM graph with k communities
OUTPUT: Community assignments \sigma

1. REGULARIZE: Compute A_reg = A + \tau/n * 11^T (small ridge)
   (Prevents leading eigenvector being dominated by high-degree nodes)

2. NORMALIZE: Compute L_sym = D^{-1/2} A_reg D^{-1/2}

3. EIGENVECTORS: Compute top k eigenvectors U \in R^{n\timesk} of L_sym

4. NORMALIZE ROWS: Let U_row = U / ||u_i||_2 (spherical projection)

5. k-MEANS: Run k-means on rows of U_row, get cluster labels \sigma

6. RETURN: \sigma (up to global permutation)

COMPLEXITY: O(n*k/\epsilon^2) for sparse graphs (k power iterations)
ACCURACY: Achieves min error rate above Kesten-Stigum threshold

H.2 Louvain Community Detection

The Louvain algorithm maximizes modularity QQ, a measure of community quality:

Q=12mij[Aijdidj2m]δ(σi,σj)Q = \frac{1}{2m} \sum_{ij} \left[ A_{ij} - \frac{d_i d_j}{2m} \right] \delta(\sigma_i, \sigma_j)

Phase 1 (local optimization): For each node vv, move vv to the neighboring community that maximizes ΔQ\Delta Q. Repeat until no improvement.

Phase 2 (aggregation): Collapse each community into a supernode. Edge weights between supernodes = total edges between original communities. Apply Phase 1 to the collapsed graph.

Repeat until no further improvement.

Complexity: O(nlogn)O(n \log n) empirically - the fastest practical community detection algorithm.

Limitation: Modularity has a resolution limit: communities smaller than m\sqrt{m} edges may not be detected. For fine-grained community structure, use alternatives (Infomap, hierarchical spectral methods).

H.3 Fast Giant Component Detection

def giant_component_fraction(A, n):
    """Compute giant component size via BFS."""
    visited = [False] * n
    max_component = 0
    
    for start in range(n):
        if visited[start]:
            continue
        # BFS from start
        queue = [start]
        visited[start] = True
        component_size = 0
        while queue:
            v = queue.pop(0)
            component_size += 1
            for u in range(n):
                if A[v][u] and not visited[u]:
                    visited[u] = True
                    queue.append(u)
        max_component = max(max_component, component_size)
    
    return max_component / n

For sparse adjacency lists (CSR format), BFS runs in O(n+m)O(n + m) - linear in the graph size.


End of 06 Random Graphs notes.


Appendix I: Advanced Topics in Random Graphs

I.1 Local Weak Convergence (Benjamini-Schramm)

For sparse graph sequences where edge density 0\to 0, graphon theory breaks down. The correct limit theory uses local weak convergence.

Definition (Benjamini-Schramm limit): A sequence of graphs GnG_n converges in the local weak sense to a random rooted graph (G,ρ)(G, \rho) if for every rooted graph (H,v)(H, v) and every r0r \ge 0:

1n{uV(Gn):Br(Gn,u)(H,v)}P[Br(G,ρ)(H,v)]\frac{1}{n} |\{u \in V(G_n) : B_r(G_n, u) \cong (H, v)\}| \to \mathbb{P}[B_r(G, \rho) \cong (H, v)]

where Br(G,u)B_r(G, u) is the ball of radius rr around uu in GG.

For G(n,c/n)G(n, c/n): The local weak limit is the Galton-Watson tree with Poisson(cc) offspring distribution - an infinite random tree. This confirms the "locally tree-like" structure of sparse ER graphs.

For BA networks: The local weak limit involves correlated degree distributions due to preferential attachment - the limiting tree is not a Galton-Watson tree but a Polya urn tree.

For SBM: The local weak limit is a multi-type Galton-Watson tree where the types are community labels. This is the probabilistic foundation of the belief propagation algorithm for community detection.

I.2 Random Regular Graphs

Definition: A dd-regular random graph on nn vertices is a graph chosen uniformly at random among all dd-regular simple graphs on nn vertices.

Construction (configuration model): Give each vertex dd stubs, pair uniformly at random, condition on simplicity.

Spectral properties: For dd-regular random graphs, the eigenvalues are in [(2ϵ)d1,d][-(2-\epsilon)\sqrt{d-1}, d] w.h.p. The Alon-Boppana bound says λ22d1o(1)\lambda_2 \ge 2\sqrt{d-1} - o(1) for any dd-regular graph. A Ramanujan graph achieves equality: λ2=2d1\lambda_2 = 2\sqrt{d-1}.

Alon conjecture (proved by Friedman, 2008): Almost all dd-regular random graphs are Ramanujan:

λ2(G)2d1+ϵ\lambda_2(G) \le 2\sqrt{d-1} + \epsilon

for any fixed ϵ>0\epsilon > 0.

For AI: Expanders (near-Ramanujan regular graphs) provide the optimal sparse attention pattern:

  • dd edges per node (linear total edges)
  • Diameter O(logn)O(\log n) (short paths)
  • Spectral gap d2d1\approx d - 2\sqrt{d-1} (fast mixing)

I.3 Random Hypergraphs

Real-world networks often have higher-order interactions - a chemistry reaction involves multiple molecules simultaneously. Hypergraphs capture this.

Definition: A hypergraph H=(V,E)H = (V, E) where edges eEe \in E can contain any number of vertices.

Random kk-uniform hypergraph Gk(n,p)G^k(n,p): Each kk-subset of VV is an edge independently with probability pp.

Phase transition: The giant component threshold for Gk(n,p)G^k(n,p) occurs at p=1/(n1k1)p = 1/\binom{n-1}{k-1} (average degree 1). The analysis uses a multi-type branching process.

For AI: Simplicial complex neural networks (SCNNs) and topological data analysis (TDA) use higher-order graph structure. Random simplicial complexes (random clique complexes of ER graphs) model the topological structure of neural network activation spaces.

I.4 Dynamic Random Graphs

Real networks evolve over time. Several models capture network dynamics:

Forest Fire model (Leskovec et al., 2007): A new node contacts a random "ambassador" and copies some of its links. Exhibits densification (average degree increases over time) and shrinking diameter - both observed in real growing networks.

Copying model: Each new node copies mm existing edges from a random source node. This generates power-law degree distributions similar to BA but with different exponent depending on copy probability.

Edge dynamics: Instead of just adding edges, allow edge rewiring, deletion, and creation. Models temporal networks (who talked to whom at time tt). The temporal analog of clustering coefficient and path length requires time-respecting paths.

For AI: Training data graphs (social networks, citation graphs) evolve over time. Distribution shift in graph ML often comes from temporal evolution of the underlying random graph model. A GNN trained on a 2019 citation graph may fail on a 2024 citation graph if the graph generative process has changed.


Appendix J: Mathematical Proofs

J.1 Proof: Giant Component Threshold (Upper Bound)

We prove: for c<1c < 1, all components have size O(logn)O(\log n) w.h.p.

Proof: Let XkX_k = number of connected components of size exactly kk in G(n,p)G(n,p) with p=c/np = c/n.

The probability that a specific set SS of kk vertices forms a component involves:

  1. The internal graph on SS being connected: probability (1p)k(k1)/2[connectivity]\ge (1-p)^{k(k-1)/2} \cdot [\text{connectivity}]
  2. No edges from SS to VSV \setminus S: probability (1p)k(nk)(1-p)^{k(n-k)}

By union bound:

E[Xk](nk)kk2pk1(1p)k(nk)\mathbb{E}[X_k] \le \binom{n}{k} \cdot k^{k-2} p^{k-1} \cdot (1-p)^{k(n-k)}

using Cayley's formula (kk2k^{k-2} labeled trees on kk vertices, each connected tree is a spanning tree of its component).

For p=c/np = c/n and kKlognk \le K \log n:

E[Xk]nkk!kk2(c/n)k1eck(nk)/n\mathbb{E}[X_k] \le \frac{n^k}{k!} \cdot k^{k-2} \cdot (c/n)^{k-1} \cdot e^{-ck(n-k)/n} ck1kk2k!neck(1k/n)\approx \frac{c^{k-1} k^{k-2}}{k! \cdot n} \cdot e^{-ck(1 - k/n)} 1n(ce1c)kk3/2\lesssim \frac{1}{n} \cdot \frac{(ce^{1-c})^k}{k^{3/2}}

(using Stirling: k!kkek2πkk! \approx k^k e^{-k} \sqrt{2\pi k}, kk2/k!ekk2/2πkk^{k-2}/k! \approx e^k k^{-2}/\sqrt{2\pi k})

For c<1c < 1: ce1c<1ce^{1-c} < 1 (since f(c)=ce1cf(c) = ce^{1-c} has f(1)=1f(1) = 1, f(1)=0f'(1) = 0, f(1)=1<0f''(1) = -1 < 0 - it's a maximum at c=1c = 1). Let α=ce1c<1\alpha = ce^{1-c} < 1.

Summing over k=2,3,,k = 2, 3, \ldots, \infty:

kE[Xk]1nkαkk3/2=Cn0\sum_k \mathbb{E}[X_k] \lesssim \frac{1}{n} \sum_k \alpha^k k^{-3/2} = \frac{C}{n} \to 0

By Markov's inequality, the total number of vertices in components of size 2\ge 2 is O(1)=o(n)O(1) = o(n), so the maximum component size is O(logn)O(\log n). \square

J.2 Proof: Poisson Degree Distribution

Claim: For G(n,p)G(n,p) with p=c/np = c/n, deg(v)dPoisson(c)\deg(v) \xrightarrow{d} \text{Poisson}(c).

Proof via PGF: The degree deg(v)=uvXuv\deg(v) = \sum_{u \neq v} X_{uv} where XuvBernoulli(c/n)X_{uv} \sim \text{Bernoulli}(c/n) i.i.d.

PGF of deg(v)\deg(v):

Gdeg(s)=E[sdeg(v)]=uvE[sXuv]=(1cn+csn)n1G_{\deg}(s) = \mathbb{E}[s^{\deg(v)}] = \prod_{u \neq v} \mathbb{E}[s^{X_{uv}}] = \left(1 - \frac{c}{n} + \frac{cs}{n}\right)^{n-1}

Taking nn \to \infty:

(1+c(s1)n)n1ec(s1)=k=0ecckk!sk\left(1 + \frac{c(s-1)}{n}\right)^{n-1} \to e^{c(s-1)} = \sum_{k=0}^\infty \frac{e^{-c} c^k}{k!} s^k

which is the PGF of Poisson(c)\text{Poisson}(c).

Since PGF convergence (for s1|s| \le 1) implies distributional convergence (by continuity theorem for generating functions), deg(v)dPoisson(c)\deg(v) \xrightarrow{d} \text{Poisson}(c). \square

Multivariate extension: For distinct vertices v1,,vmv_1, \ldots, v_m, their degrees are jointly Poisson in the limit, with joint PGF:

E[i=1msideg(vi)]eici(si1)\mathbb{E}\left[\prod_{i=1}^m s_i^{\deg(v_i)}\right] \to e^{\sum_i c_i(s_i - 1)}

where ci=cc_i = c for all ii. But the joint distribution is NOT independent Poisson (edges between viv_i and vjv_j contribute to both deg(vi)\deg(v_i) and deg(vj)\deg(v_j)). For fixed mm, the correlation between degrees of v1v_1 and v2v_2 is p=c/n0p = c/n \to 0, so they are asymptotically independent.

J.3 Proof sketch: Davis-Kahan Theorem

Simplified version: Let A=Aˉ+WA = \bar{A} + W where Aˉ\bar{A} has eigenvalue λˉ\bar{\lambda} and unit eigenvector uˉ\bar{u}. Let u^\hat{u} be the unit eigenvector of AA corresponding to eigenvalue λ^\hat{\lambda} nearest to λˉ\bar{\lambda}. Let δ=minμσ(Aˉ){λˉ}λˉμ\delta = \min_{\mu \in \sigma(\bar{A}) \setminus \{\bar{\lambda}\}} |\bar{\lambda} - \mu| (gap to other eigenvalues).

Claim: sin(u^,uˉ)Wop/(δWop)\sin\angle(\hat{u}, \bar{u}) \le \|W\|_{op} / (\delta - \|W\|_{op}) (assuming δ>Wop\delta > \|W\|_{op}).

Proof: Decompose u^=αuˉ+βv\hat{u} = \alpha \bar{u} + \beta v where vuˉv \perp \bar{u}, α2+β2=1|\alpha|^2 + |\beta|^2 = 1, and sin(u^,uˉ)=β\sin\angle(\hat{u}, \bar{u}) = |\beta|.

From Au^=λ^u^A\hat{u} = \hat{\lambda}\hat{u}: Aˉu^+Wu^=λ^u^\bar{A}\hat{u} + W\hat{u} = \hat{\lambda}\hat{u}.

Project onto uˉ\bar{u}^\perp: PuˉAˉPuˉ(βv)+PuˉWu^=λ^βvP_{\bar{u}^\perp} \bar{A} P_{\bar{u}^\perp} (\beta v) + P_{\bar{u}^\perp} W \hat{u} = \hat{\lambda} \beta v.

All eigenvalues of PuˉAˉPuˉP_{\bar{u}^\perp} \bar{A} P_{\bar{u}^\perp} are at distance δ\ge \delta from λ^\hat{\lambda} (which is close to λˉ\bar{\lambda}):

(PuˉAˉPuˉλ^I)1op1δλ^λˉ\|(P_{\bar{u}^\perp} \bar{A} P_{\bar{u}^\perp} - \hat{\lambda} I)^{-1}\|_{op} \le \frac{1}{\delta - |\hat{\lambda} - \bar{\lambda}|}

Therefore:

β=Puˉ(PuˉAˉPuˉλ^I)1PuˉWu^WopδWop|\beta| = \|P_{\bar{u}^\perp}(P_{\bar{u}^\perp} \bar{A} P_{\bar{u}^\perp} - \hat{\lambda} I)^{-1} P_{\bar{u}^\perp} W \hat{u}\| \le \frac{\|W\|_{op}}{\delta - \|W\|_{op}}

This gives the Davis-Kahan bound. \square


Appendix K: Notation Reference

SymbolMeaningFirst appears
G(n,p)G(n,p)Erdos-Renyi random graph, nn vertices, edge prob pp3.1
G(n,m)G(n,m)ER graph with exactly mm edges3.1
L1(G)L_1(G)Size of largest connected component3.3
β(c)\beta(c)Giant component fraction, β=1ecβ\beta = 1 - e^{-c\beta}3.3
CvC_vLocal clustering coefficient of vertex vv4.2
LLAverage path length4.3
Π(v)\Pi(v)Preferential attachment probability of vertex vv5.1
SBM(n,k,σ,B)\text{SBM}(n, k, \sigma, B)Stochastic Block Model6.1
B[0,1]k×kB \in [0,1]^{k\times k}SBM block probability matrix6.1
σ:[n][k]\sigma: [n] \to [k]Community assignment6.1
ρ(M)\rho(M)Spectral radius of matrix MMApp. A.2
μsc\mu_{sc}Wigner semicircle measure7.1
d(G,H)d_\square(G, H)Cut metric between graphs GG and HH8.1
W:[0,1]2[0,1]W: [0,1]^2 \to [0,1]Graphon8.2
t(F,W)t(F, W)Homomorphism density of FF in WW8.3
TWT_WGraphon integral operator, TWh(x)=W(x,y)h(y)dyT_Wh(x) = \int W(x,y)h(y)dy8.4
w.h.p.\text{w.h.p.}With high probability (probability 1\to 1)2.2
o(),O(),Θ(),ω()o(\cdot), O(\cdot), \Theta(\cdot), \omega(\cdot)Asymptotic notation2.2
I(c)=c1lncI(c) = c - 1 - \ln cLarge deviation function for ER3.3
ϕ(s)\phi(s)Probability generating functionApp. A.1
qkq_kExcess degree distributionApp. B.2

<- Back to Graph Theory | Next: Graph Algorithms ->


Appendix L: Worked Examples

L.1 Computing the Giant Component Fraction

Problem: For G(n,p)G(n,p) with p=2.5/np = 2.5/n, find the theoretical fraction of vertices in the giant component.

Solution: We need β\beta satisfying β=1e2.5β\beta = 1 - e^{-2.5\beta}.

Define f(β)=1e2.5ββf(\beta) = 1 - e^{-2.5\beta} - \beta. We need f(β)=0f(\beta) = 0.

  • f(0)=0f(0) = 0 (trivial solution - subcritical regime would have this as the only root)
  • f(β)=2.5e2.5β1f'(\beta) = 2.5 e^{-2.5\beta} - 1; f(0)=1.5>0f'(0) = 1.5 > 0 (slope at 0 is positive)
  • ff is concave for β>0\beta > 0, so there is one non-trivial root

Newton's method: Starting from β0=0.7\beta_0 = 0.7:

  • f(0.7)=1e1.750.7=10.17380.7=0.1262f(0.7) = 1 - e^{-1.75} - 0.7 = 1 - 0.1738 - 0.7 = 0.1262
  • f(0.7)=2.50.17381=0.5655f'(0.7) = 2.5 \cdot 0.1738 - 1 = -0.5655
  • β1=0.70.1262/(0.5655)=0.7+0.2232=0.923\beta_1 = 0.7 - 0.1262/(-0.5655) = 0.7 + 0.2232 = 0.923 (overshoot, try smaller)

Using bisection between 0.7 and 0.95:

  • f(0.8)=1e20.8=10.13530.8=0.0647>0f(0.8) = 1 - e^{-2} - 0.8 = 1 - 0.1353 - 0.8 = 0.0647 > 0
  • f(0.85)=1e2.1250.85=10.11940.85=0.0306>0f(0.85) = 1 - e^{-2.125} - 0.85 = 1 - 0.1194 - 0.85 = 0.0306 > 0
  • f(0.88)10.11080.88=0.0092>0f(0.88) \approx 1 - 0.1108 - 0.88 = 0.0092 > 0
  • f(0.89)10.10840.89=0.0016>0f(0.89) \approx 1 - 0.1084 - 0.89 = 0.0016 > 0
  • f(0.895)10.10720.895=0.0022<0f(0.895) \approx 1 - 0.1072 - 0.895 = -0.0022 < 0

So β0.892\beta \approx 0.892 - about 89.2% of vertices are in the giant component.

Interpretation: At average degree 2.5, the network is well into the supercritical regime. The vast majority of vertices are connected in one giant component, leaving only about 10.8% in small satellite components.

L.2 Kesten-Stigum Threshold Calculation

Problem: For the 2-block SBM with a=15a = 15 and b=4b = 4, determine: (a) Is community detection possible? (b) Can we achieve exact recovery?

Solution:

(a) Detection (weak recovery): Kesten-Stigum threshold: (ab)2>2(a+b)(a-b)^2 > 2(a+b)

(154)2=112=121(15-4)^2 = 11^2 = 121

2(15+4)=219=382(15+4) = 2 \cdot 19 = 38

121>38121 > 38 OK - Detection is possible.

SNR =(ab)2/(2(a+b))=121/383.181= (a-b)^2 / (2(a+b)) = 121/38 \approx 3.18 \gg 1.

(b) Exact recovery: Need (ab)2>2(\sqrt{a} - \sqrt{b})^2 > 2 (scaled threshold for logarithmic degree regime).

153.873\sqrt{15} \approx 3.873, 4=2\sqrt{4} = 2.

(154)2=(3.8732)2=(1.873)2=3.51>2(\sqrt{15} - \sqrt{4})^2 = (3.873 - 2)^2 = (1.873)^2 = 3.51 > 2 OK - Exact recovery is achievable.

Interpretation: With a=15a = 15 and b=4b = 4, we have a relatively easy community detection problem - both detection and exact recovery are achievable. Spectral clustering should work well here.

L.3 Small-World Parameter Calculation

Problem: Design a WS graph on n=1000n = 1000 nodes that approximates the C. elegans neural connectome: C0.28C \approx 0.28, L2.65L \approx 2.65, k14k \approx 14.

Solution:

Step 1: Initial ring lattice has C(0)=3(k2)/(4(k1))=312/(413)=36/520.692C(0) = 3(k-2)/(4(k-1)) = 3 \cdot 12/(4 \cdot 13) = 36/52 \approx 0.692.

Step 2: Target clustering C(β)0.28C(\beta) \approx 0.28. Using C(β)C(0)(1β)3C(\beta) \approx C(0)(1-\beta)^3:

0.280.692(1β)30.28 \approx 0.692 (1-\beta)^3 (1β)30.404(1-\beta)^3 \approx 0.404 1β0.739,β0.2611-\beta \approx 0.739, \quad \beta \approx 0.261

Step 3: Verify path length at β=0.261\beta = 0.261. Using the WS approximation L(β)nkf(nkβ/2)L(\beta) \approx \frac{n}{k} \cdot f(nk\beta/2) where f(u)loguuf(u) \approx \frac{\log u}{u} for large uu:

nkβ/2=1000140.261/2=1827nk\beta/2 = 1000 \cdot 14 \cdot 0.261 / 2 = 1827

L(1000/14)log(1827)/182771.47.51/18270.29L \approx (1000/14) \cdot \log(1827)/1827 \approx 71.4 \cdot 7.51/1827 \approx 0.29

This is too small - the approximation breaks down at large β\beta. Numerically, L(β=0.26)3.5L(\beta = 0.26) \approx 3.5 for n=1000n=1000, k=14k=14, which is reasonably close to the target L=2.65L = 2.65.

Conclusion: WS parameters (n=1000,k=14,β0.26)(n=1000, k=14, \beta \approx 0.26) produce a graph close to C. elegans in both clustering and path length, validating the small-world model.

L.4 Graphon Estimation from Data

Problem: Given a graph GG with 100 nodes known to be sampled from a 3-block SBM, estimate the graphon.

Procedure:

  1. Run spectral clustering with k=3k=3 to get estimated community labels σ^\hat{\sigma}.

  2. Sort vertices by σ^\hat{\sigma}: reorder adjacency matrix so community 1 nodes come first, then community 2, then community 3.

  3. Estimate block probabilities: For communities r,sr, s:

B^rs={(u,v)E:σ^(u)=r,σ^(v)=s}{(u,v):σ^(u)=r,σ^(v)=s}\hat{B}_{rs} = \frac{|\{(u,v) \in E : \hat{\sigma}(u) = r, \hat{\sigma}(v) = s\}|}{|\{(u,v) : \hat{\sigma}(u) = r, \hat{\sigma}(v) = s\}|}
  1. Construct step-function graphon:
W^(x,y)=B^3x,3y\hat{W}(x, y) = \hat{B}_{\lceil 3x \rceil, \lceil 3y \rceil}

(piecewise constant on [0,1]2[0,1]^2 divided into 3×33 \times 3 blocks)

  1. Evaluate quality: Compute cut distance d(W^,W)d_\square(\hat{W}, W^*) where WW^* is the true graphon. The cut distance converges to 0 as nn \to \infty.

Error bound: For a kk-block SBM, the best graphon estimator achieves error O(k/n)O(k/\sqrt{n}) in cut distance (minimax optimal). With n=100n = 100 and k=3k = 3, expected cut distance 3/10=0.3\approx 3/10 = 0.3 - substantial estimation uncertainty.


Appendix M: Connections to Statistical Physics

M.1 Random Graphs and Spin Glasses

The Stochastic Block Model community detection problem is isomorphic to the ferromagnetic Ising model on the graph:

  • Community labels σv{+1,1}\sigma_v \in \{+1, -1\} correspond to spin states
  • Edges within communities are "ferromagnetic" (prefer aligned spins)
  • Edges between communities are "antiferromagnetic" (prefer anti-aligned)

The Kesten-Stigum threshold corresponds to the Nishimori temperature in the disordered Ising model - the temperature at which the magnetization (overlap with ground truth) first becomes nonzero.

Belief propagation = Cavity method: The belief propagation algorithm for community detection in SBM is the Bethe approximation applied to the Ising model. Near the KS threshold, BP is asymptotically optimal - no polynomial-time algorithm can do better.

M.2 Percolation and Statistical Mechanics

Bond percolation on Z2\mathbb{Z}^2 is a model in statistical mechanics. Its critical phenomena:

  • Order parameter: P(ρ)=P[vertex is in infinite component]P_\infty(\rho) = \mathbb{P}[\text{vertex is in infinite component}]
  • Critical exponent: P(ρ)(ρρc)βP_\infty(\rho) \sim (\rho - \rho_c)^\beta with β=5/36\beta = 5/36 (exact, 2D)
  • Correlation length: ξ(ρ)ρρcν\xi(\rho) \sim |\rho - \rho_c|^{-\nu} with ν=4/3\nu = 4/3 (exact, 2D)

For ER graphs: P(c)=β(c)P_\infty(c) = \beta(c) with critical exponent 1 (mean-field universality class, since ER has "infinite dimension").

Conformal invariance (2D percolation): Near criticality, 2D percolation is conformally invariant - the scaling limit is described by SLE (Schramm-Loewner Evolution). This deep connection between combinatorics and complex analysis has no direct ML application yet, but illustrates the richness of the field.

M.3 Free Energy and the Replica Method

The replica method is a non-rigorous but powerful physics technique for computing expectations over random graphs.

For the SBM community detection problem, the free energy (log-partition function) per vertex is:

f=limn1nE[logZ(σ,G)]f = \lim_{n \to \infty} \frac{1}{n} \mathbb{E}[\log Z(\sigma, G)]

where Z=σeH(σ,G)Z = \sum_\sigma e^{H(\sigma, G)} and HH is the log-likelihood of the community assignment.

The replica calculation predicts the exact phase diagram of the SBM - both the KS threshold and the exact recovery threshold - and was later made rigorous using interpolation methods (Guerra, Talagrand).

ML connection: Free energy calculations in statistical physics are the rigorous foundation of variational inference in machine learning. The Bethe free energy (used in belief propagation) is the physics analog of the ELBO (evidence lower bound) in variational autoencoders.


End of 06-Random-Graphs notes.


Appendix N: Extended Exercise Solutions

N.1 Solution Notes for Exercise 1 (Phase Transition)

Key implementation details:

The fixed-point equation β=1ecβ\beta = 1 - e^{-c\beta} can be solved numerically via Newton's method:

βk+1=βkβk1+ecβk1cecβk\beta_{k+1} = \beta_k - \frac{\beta_k - 1 + e^{-c\beta_k}}{1 - ce^{-c\beta_k}}

Starting from β0=1ec\beta_0 = 1 - e^{-c} (one step of Picard iteration), Newton's method converges in 5-10 iterations for c[1,5]c \in [1, 5].

For c1c \le 1: the only fixed point is β=0\beta = 0 (return 0). For c>1c > 1: there are two fixed points (0 and the positive root); return the positive root.

Expected results table:

ccTheoretical β(c)\beta(c)Simulated L1/nL_1/n (variance)
0.50O(logn/n)0.004O(\log n / n) \approx 0.004
0.80O(logn/n)0.006O(\log n / n) \approx 0.006
1.00 (but n1/3n^{-1/3} scaling)0.15n1/3\approx 0.15 \cdot n^{-1/3}
1.50.5830.583±0.0150.583 \pm 0.015
2.00.7970.797±0.0080.797 \pm 0.008
2.50.8920.892±0.0050.892 \pm 0.005
3.00.9400.940±0.0030.940 \pm 0.003

Why L2L_2 peaks at criticality: The second-largest component size peaks at c=1c = 1 (size n2/3\sim n^{2/3}) because this is where the giant component is just forming - there are many large components competing. For c>1c > 1, the giant component absorbs everything, leaving only O(logn)O(\log n) satellites.

N.2 Solution Notes for Exercise 4 (Community Detection)

Spectral algorithm implementation:

def spectral_community_detection(A, k=2):
    """Spectral clustering for SBM community detection."""
    n = A.shape[0]
    # Compute degree matrix and normalized Laplacian
    d = A.sum(axis=1)
    D_inv_sqrt = np.diag(1.0 / np.sqrt(d + 1e-10))
    L_sym = np.eye(n) - D_inv_sqrt @ A @ D_inv_sqrt
    
    # Eigendecomposition (smallest eigenvalues = community structure)
    eigvals, eigvecs = np.linalg.eigh(L_sym)
    
    # Second eigenvector (first non-trivial)
    u2 = eigvecs[:, 1]
    
    # Threshold at 0
    labels = (u2 > 0).astype(int)
    return labels

def community_accuracy(labels_est, labels_true):
    """Fraction correct, up to global flip."""
    acc1 = np.mean(labels_est == labels_true)
    acc2 = np.mean(labels_est == (1 - labels_true))
    return max(acc1, acc2)

Expected accuracy table:

(a,b)(a, b)SNR = (ab)2/(2(a+b))(a-b)^2/(2(a+b))RegimeExpected accuracy
(20,5)(20, 5)225/50=4.5225/50 = 4.5Well above KS0.95-0.99
(10,5)(10, 5)25/30=0.8325/30 = 0.83Below KS0.5\approx 0.5 (random)
(6,4)(6, 4)4/20=0.24/20 = 0.2Below KS0.5\approx 0.5 (random)
(8,3)(8, 3)25/22=1.1425/22 = 1.14Just above KS0.55-0.65

N.3 Solution Notes for Exercise 8 (Preferential Attachment)

Efficient alias sampling for preferential attachment:

The naive approach (linear scan to sample proportional to degree) is O(n)O(n) per edge, giving O(n2)O(n^2) total. For large nn, use the alias method:

  1. Maintain a list of (dv,v)(d_v, v) pairs for all existing nodes
  2. Use the alias method to sample from this distribution in O(1)O(1) per sample
  3. After adding new edges, update the alias table in O(m)O(m) per step

Alternatively, use the Vose-Walker alias method which supports updates efficiently.

Simpler O(nlogn)O(n \log n) approach: Maintain a binary indexed tree (Fenwick tree) over cumulative degrees. Sampling is O(logn)O(\log n) per edge, updating is O(logn)O(\log n) per edge, giving O(nmlogn)O(nm \log n) total.

Power law fit: Maximum likelihood estimator for power-law exponent on data k1,,kmk_1, \ldots, k_m with kikmink_i \ge k_{\min}:

γ^=1+m[i=1mlnkikmin0.5]1\hat{\gamma} = 1 + m \left[\sum_{i=1}^m \ln\frac{k_i}{k_{\min} - 0.5}\right]^{-1}

For BA with m=2m = 2 and kmin=10k_{\min} = 10: expect γ^3.0±0.2\hat{\gamma} \approx 3.0 \pm 0.2 for n=10000n = 10000.


Appendix O: Further Reading

O.1 Textbooks

  1. Bollobas, B. (2001). Random Graphs (2nd ed.). Cambridge University Press.

    • The definitive mathematical treatment; covers ER theory exhaustively.
  2. Janson, S., Luczak, T., Rucinski, A. (2000). Random Graphs. Wiley.

    • More accessible than Bollobas; covers first and second moment methods thoroughly.
  3. Lovasz, L. (2012). Large Networks and Graph Limits. AMS.

    • The definitive treatment of graphon theory by its creator.
  4. Durrett, R. (2007). Random Graph Dynamics. Cambridge University Press.

    • Dynamical random graphs and their applications to epidemics and social networks.

O.2 Foundational Papers

  1. Erdos, P., Renyi, A. (1960). On the evolution of random graphs. Magyar Tud. Akad. Mat. Kutato Int. Kozl., 5, 17-61.

  2. Watts, D.J., Strogatz, S.H. (1998). Collective dynamics of 'small-world' networks. Nature, 393, 440-442.

  3. Barabasi, A.-L., Albert, R. (1999). Emergence of scaling in random networks. Science, 286, 509-512.

  4. Lovasz, L., Szegedy, B. (2006). Limits of dense graph sequences. J. Combin. Theory Ser. B, 96, 933-957.

  5. Mossel, E., Neeman, J., Sly, A. (2015). Reconstruction and estimation in the planted partition model. Probab. Theory Related Fields, 162, 431-461.

  6. Abbe, E., Sandon, C. (2015). Community detection in the stochastic block models by spectral methods. arXiv:1503.00609.

O.3 ML-Specific Papers

  1. Palowitch, J. et al. (2022). GraphWorld: Fake Graphs Bring Real Insights for GNNs. KDD 2022.

  2. Keriven, N., Peyre, G. (2019). Universal Invariant and Equivariant Graph Neural Networks. NeurIPS 2019.

  3. Vignac, C. et al. (2022). DiGress: Discrete Denoising diffusion for graph generation. ICLR 2023.

  4. Rusch, T.K., Bronstein, M.M., Mishra, S. (2023). A survey on oversmoothing in graph neural networks. arXiv:2303.10993.

  5. Broido, A.D., Clauset, A. (2019). Scale-free networks are rare. Nature Communications, 10, 1017.


<- Back to Graph Theory | Next: Graph Algorithms ->


Appendix P: Summary of Key Inequalities

P.1 Concentration Inequalities for Random Graphs

Markov's inequality: For non-negative XX:

P[Xt]E[X]t\mathbb{P}[X \ge t] \le \frac{\mathbb{E}[X]}{t}

Chebyshev's inequality:

P[XE[X]t]Var(X)t2\mathbb{P}[|X - \mathbb{E}[X]| \ge t] \le \frac{\text{Var}(X)}{t^2}

Chernoff bound (Poisson random variables): For XPoisson(μ)X \sim \text{Poisson}(\mu):

P[X(1+δ)μ]eμδ2/(2+δ)\mathbb{P}[X \ge (1+\delta)\mu] \le e^{-\mu \delta^2 / (2+\delta)} P[X(1δ)μ]eμδ2/2\mathbb{P}[X \le (1-\delta)\mu] \le e^{-\mu \delta^2 / 2}

Paley-Zygmund inequality: For non-negative XX with finite second moment:

P[X>0](E[X])2E[X2]\mathbb{P}[X > 0] \ge \frac{(\mathbb{E}[X])^2}{\mathbb{E}[X^2]}

Azuma-Hoeffding (Martingale concentration): If (X0,X1,,Xm)(X_0, X_1, \ldots, X_m) is a martingale with XkXk1ck|X_k - X_{k-1}| \le c_k:

P[XmX0t]2exp(t22kck2)\mathbb{P}[|X_m - X_0| \ge t] \le 2\exp\left(-\frac{t^2}{2\sum_k c_k^2}\right)

For random graph properties: reveal edges one at a time. Each edge revelation changes the property value by at most ckc_k (Lipschitz constant of the property). Azuma-Hoeffding gives concentration of order m=O(n)\sqrt{m} = O(n) around the mean.

McDiarmid's inequality (Bounded differences): If f(G)f(G) changes by at most cc when one edge is added/removed:

P[f(G)E[f(G)]t]2exp(t22(n2)c2)\mathbb{P}[|f(G) - \mathbb{E}[f(G)]| \ge t] \le 2\exp\left(-\frac{t^2}{2\binom{n}{2}c^2}\right)

Applications: triangle count (c=O(n)c = O(n) per edge change), largest clique (c=1c = 1), chromatic number (c=1c = 1).

P.2 Spectral Inequalities

Perron-Frobenius: For non-negative irreducible AA, λ1(A)>0\lambda_1(A) > 0 and the leading eigenvector has all positive entries.

Courant-Fischer (Min-Max): The kk-th eigenvalue of symmetric AA satisfies:

λk(A)=mindimV=nk+1maxxV,x=1xAx\lambda_k(A) = \min_{\dim V = n-k+1} \max_{\mathbf{x} \in V, \|\mathbf{x}\|=1} \mathbf{x}^\top A \mathbf{x}

Weyl's theorem: For symmetric AA and EE:

λk(A+E)λk(A)Eopk|\lambda_k(A+E) - \lambda_k(A)| \le \|E\|_{op} \quad \forall k

Bauer-Fike: If AA is diagonalizable with condition number κ\kappa, eigenvalue perturbations are bounded by κE\kappa \|E\|. For symmetric AA: κ=1\kappa = 1 (always), recovering Weyl's theorem.

Cheeger inequality: For graph Laplacian LL, the Cheeger constant h(G)=minS:Sn/2E(S,Sˉ)/Sh(G) = \min_{S: |S| \le n/2} |E(S, \bar{S})| / |S| satisfies:

λ22h(G)2λ2\frac{\lambda_2}{2} \le h(G) \le \sqrt{2\lambda_2}

This is the fundamental connection between algebraic (spectral gap) and geometric (cut quality) properties of graphs.


<- Back to Graph Theory | Next: Graph Algorithms ->


Appendix Q: Quick Reference Card

RANDOM GRAPH QUICK REFERENCE
========================================================================

  ERDOS-RENYI G(n,p)
  ------------------
  - Average degree:   np
  - Degree dist:      Poisson(np) as n->\infty
  - Giant component:  exists iff p > 1/n  ->  fraction \beta(c) w/ c=np
  - Connectivity:     w.h.p. iff p \geq ln(n)/n
  - Diameter:         ~ log(n)/log(np) when connected
  - Clustering:       ~ p -> 0  (locally tree-like)

  WATTS-STROGATZ (n, k, \beta)
  -------------------------
  - Degree:            \approx k (Poisson-like spread from rewiring)
  - Clustering:        C(0)(1-\beta)^3  where C(0) \approx 3/4 for large k
  - Path length:       O(log n) for any \beta > 0
  - Small-world:       \beta \in [1/(nk), 0.3] gives C\ggC_ER and L\approxL_ER

  BARABASI-ALBERT (n, m)
  -----------------------
  - Degree dist:       P(k) ~ 2m^2/k^3  (power law \gamma=3)
  - Max degree:        ~ m\sqrtn  (oldest node)
  - Diameter:          ~ log(n)/log(log(n))
  - Clustering:        C ~ (log n)^2/n -> 0  (no clustering!)

  STOCHASTIC BLOCK MODEL SBM(n,k,\sigma,B)
  -------------------------------------
  - KS threshold:      (a-b)^2 = 2(a+b)  for 2-block, p=a/n, q=b/n
  - Exact recovery:    (\sqrta - \sqrtb)^2 = 2   for log-degree regime
  - Spectral alg:      works above KS threshold
  - GNN limit:         No GNN beats KS threshold on SBM data

  GRAPHONS W:[0,1]^2->[0,1]
  -------------------------
  - Dense graph limit: every dense G-sequence converges to a graphon
  - Sampling:          draw \xi^i~U[0,1]; edge (i,j) w.p. W(\xi^i,\xi_j)
  - ER graphon:        W(x,y) = p  (constant)
  - SBM graphon:       W(x,y) = B_{\lceilkx\rceil,\lceilky\rceil}  (step function)
  - Operator:          T_W h(x) = \int_0^1 W(x,y)h(y)dy  (Hilbert-Schmidt)

========================================================================