Tutorials › Stochastic Processes › Stationary Distributions for Random Walks on Graphs

Reversibility and Detailed Balance · Tutorial 267 of 994

Stationary Distributions for Random Walks on Graphs

Learn why a simple random walk on a finite connected undirected graph has a stationary distribution proportional to vertex degree, and how to verify it using detailed balance.

Advanced 9 min read

What You'll Learn

  • Define the simple random walk transition matrix from the neighbor sets of an undirected graph.
  • Derive the degree-proportional probability vector and verify that it is normalized.
  • Prove detailed balance for every edge and stationarity for every vertex.
  • Prove uniqueness of the stationary distribution for a finite connected graph.
  • Check the result on paths, cycles, and star graphs using exact calculations.
  • Distinguish a stationary distribution from a limiting distribution.

Why Vertex Degree Determines Stationary Mass

A random walk on an undirected graph chooses one of the current vertex’s neighbors uniformly at each step. A vertex with many neighbors sends probability away along many possible edges, but it can also be entered from many neighboring vertices. At equilibrium, these two effects balance: the stationary probability at a vertex is proportional to its number of neighbors. We will derive that distribution and verify the balance on every edge.

Let \(G=(V,E)\) be a finite, connected, undirected simple graph with at least two vertices. “Simple” means there are no loops or multiple edges. Write \(i\sim j\) when \(\{i,j\}\in E\), and let \(d(i)\) be the number of neighbors of \(i\). Connectedness and the assumption \(|V|\ge2\) imply \(d(i)\ge1\) for every vertex. On a probability space \((\Omega,\mathcal{F},\mathbb{P})\), let \((X_n)_{n\ge0}\) be the discrete-time Markov chain with state space \(V\), transition matrix \(P=(p_{ij})\), and initial distribution \(\mu\), a row vector. Its transition probabilities are

$$ p_{ij}= \begin{cases} \dfrac{1}{d(i)}, & j\sim i,\\[4pt] 0, & j\not\sim i. \end{cases} $$

For each \(i\), there are exactly \(d(i)\) neighbors, each assigned probability \(1/d(i)\), and every other transition has probability zero. Thus \(\sum_{j\in V}p_{ij}=d(i)/d(i)=1\): \(P\) is row-stochastic. A probability row vector \(\pi\) is stationary if \(\pi P=\pi\); starting the chain with distribution \(\pi\) then leaves its one-time marginal distribution unchanged at each step.

Theorem: For a finite, connected, undirected simple graph with at least two vertices, the simple random walk has the stationary distribution \(\displaystyle \pi_i=\frac{d(i)}{\sum_{k\in V}d(k)}=\frac{d(i)}{2|E|}\). For every pair of vertices, it satisfies detailed balance, \(\pi_i p_{ij}=\pi_j p_{ji}\). This stationary distribution is unique.

Derivation by Balancing Each Edge

Detailed balance asks that, for each ordered pair \(i,j\), the stationary probability flow from \(i\) to \(j\) equal the flow from \(j\) to \(i\). For an undirected graph, a natural candidate assigns the same stationary flow to each direction of every edge. If \(i\sim j\), the transition probability out of \(i\) along that edge is \(1/d(i)\). Choosing \(\pi_i\) proportional to \(d(i)\) makes the product \(\pi_i p_{ij}\) independent of the vertex degree.

The denominator \(2|E|\) follows by counting vertex-edge incidences. Each edge has two endpoints, so counting incidences by edges gives \(2|E|\); counting them by vertices gives \(\sum_{i\in V}d(i)\). Consequently, \(\sum_i d(i)=2|E|\), and the proposed probabilities sum to one.

Proof. Set \(D=\sum_{k\in V}d(k)=2|E|\), and define \(\pi_i=d(i)/D\). Since every degree is positive and the sum of the degrees is \(D\), each \(\pi_i\) is nonnegative and \(\sum_i\pi_i=1\). If \(i\sim j\), then \(\pi_i p_{ij}=(d(i)/D)(1/d(i))=1/D\), and, because the graph is undirected, \(\pi_j p_{ji}=(d(j)/D)(1/d(j))=1/D\). If \(i\not\sim j\), then \(p_{ij}=p_{ji}=0\), so both flows are zero. Thus detailed balance holds for all pairs. For a fixed \(j\), it follows that \(\sum_i\pi_i p_{ij}=\sum_i\pi_j p_{ji}=\pi_j\sum_i p_{ji}\). Here \(p_{ji}\), as \(i\) ranges over \(V\), is row \(j\) of \(P\), so its sum is \(1\). Hence \(\sum_i\pi_i p_{ij}=\pi_j\), proving \(\pi P=\pi\). \(\square\)

There is also a direct reason the candidate works: every neighbor of \(j\) sends the same stationary flow \(1/D\) into \(j\), and there are \(d(j)\) such neighbors. The total incoming flow is therefore \(d(j)/D=\pi_j\). The proof above establishes the same fact while also checking detailed balance for nonedges.

Uniqueness. Connectedness rules out separate components that could carry different stationary distributions. The following argument proves uniqueness directly, without needing a convergence claim.

Proof. Let \(\nu\) be any stationary probability distribution for this chain, so \(\nu P=\nu\), and define \(r_i=\nu_i/\pi_i\); this ratio is defined because \(\pi_i>0\). For each \(j\), stationarity and detailed balance give \(\displaystyle r_j=\frac{\nu_j}{\pi_j}=\sum_i\frac{\nu_i p_{ij}}{\pi_j}=\sum_i r_i\frac{\pi_i p_{ij}}{\pi_j}=\sum_i r_i p_{ji}\). The last expression is a weighted average of the values \(r_i\) at the neighbors of \(j\): its weights are \(p_{ji}=1/d(j)\) for those neighbors and zero otherwise. Since \(V\) is finite, \(r\) has a maximum, say at \(j\). Its average over the neighbors of \(j\) equals this maximum. Each neighbor’s value is at most the maximum, so every neighbor must also have the maximum value; otherwise the average would be smaller. Repeating this argument along paths, connectedness implies that every \(r_i\) equals the same constant \(c\). Thus \(\nu_i=c\pi_i\) for every \(i\). Summing over \(i\) gives \(1=c\cdot1\), so \(c=1\) and \(\nu=\pi\). \(\square\)

Worked Examples

Worked Example: A Four-Vertex Path

Consider the path with vertices \(1,2,3,4\) and edges \(\{1,2\},\{2,3\},\{3,4\}\). Its degrees are \(d(1)=1\), \(d(2)=2\), \(d(3)=2\), and \(d(4)=1\). Their sum is \(1+2+2+1=6=2\cdot3=2|E|\). In vertex order \(1,2,3,4\), the transition matrix is

$$ P= \begin{bmatrix} 0&1&0&0\\ \tfrac12&0&\tfrac12&0\\ 0&\tfrac12&0&\tfrac12\\ 0&0&1&0 \end{bmatrix}. $$

Check each row: \(0+1+0+0=1\); \(\tfrac12+0+\tfrac12+0=1\); \(0+\tfrac12+0+\tfrac12=1\); and \(0+0+1+0=1\). The degree formula gives \(\pi=(\tfrac16,\tfrac13,\tfrac13,\tfrac16)\), whose entries sum to \(\tfrac16+\tfrac13+\tfrac13+\tfrac16=1\).

Multiplication using row-vector convention gives \(\pi P=(\tfrac13\cdot\tfrac12,\ \tfrac16+\tfrac13\cdot\tfrac12,\ \tfrac13\cdot\tfrac12+\tfrac16,\ \tfrac13\cdot\tfrac12)=(\tfrac16,\tfrac13,\tfrac13,\tfrac16)=\pi\). For the three edges, the flow in each direction is respectively \(\pi_1p_{12}=\tfrac16\cdot1=\tfrac16=\tfrac13\cdot\tfrac12=\pi_2p_{21}\), \(\pi_2p_{23}=\tfrac13\cdot\tfrac12=\tfrac16=\tfrac13\cdot\tfrac12=\pi_3p_{32}\), and \(\pi_3p_{34}=\tfrac13\cdot\tfrac12=\tfrac16=\tfrac16\cdot1=\pi_4p_{43}\).

Worked Example: A Triangle

For the triangle on vertices \(1,2,3\), every vertex has degree \(2\). The degree sum is \(2+2+2=6=2\cdot3=2|E|\), so the proposed stationary distribution is \(\pi=(\tfrac13,\tfrac13,\tfrac13)\). Each vertex moves to either of the other two with probability \(\tfrac12\), giving

$$ P= \begin{bmatrix} 0&\tfrac12&\tfrac12\\ \tfrac12&0&\tfrac12\\ \tfrac12&\tfrac12&0 \end{bmatrix}. $$

Each row sums to \(0+\tfrac12+\tfrac12=1\). Multiplying, \(\pi P=(\tfrac13\cdot0+\tfrac13\cdot\tfrac12+\tfrac13\cdot\tfrac12,\ \tfrac13\cdot\tfrac12+\tfrac13\cdot0+\tfrac13\cdot\tfrac12,\ \tfrac13\cdot\tfrac12+\tfrac13\cdot\tfrac12+\tfrac13\cdot0)=(\tfrac13,\tfrac13,\tfrac13)\). Every edge has flow \(\tfrac13\cdot\tfrac12=\tfrac16\) in each direction, so detailed balance holds on all three edges.

Worked Example: A Star with Three Leaves

Let vertex \(1\) be the center of a star, connected to leaves \(2,3,4\), with no other edges. The degrees are \(d(1)=3\) and \(d(2)=d(3)=d(4)=1\), giving degree sum \(3+1+1+1=6=2\cdot3=2|E|\). Thus \(\pi=(\tfrac12,\tfrac16,\tfrac16,\tfrac16)\). The transition matrix is

$$ P= \begin{bmatrix} 0&\tfrac13&\tfrac13&\tfrac13\\ 1&0&0&0\\ 1&0&0&0\\ 1&0&0&0 \end{bmatrix}. $$

The center row sums to \(0+\tfrac13+\tfrac13+\tfrac13=1\); each leaf row sums to \(1+0+0+0=1\). The incoming stationary mass at the center is \(\tfrac16\cdot1+\tfrac16\cdot1+\tfrac16\cdot1=\tfrac12\). At each leaf it is \(\tfrac12\cdot\tfrac13=\tfrac16\). Therefore \(\pi P=(\tfrac12,\tfrac16,\tfrac16,\tfrac16)=\pi\). On each edge \(\{1,j\}\), with \(j\in\{2,3,4\}\), the two flows are \(\pi_1p_{1j}=\tfrac12\cdot\tfrac13=\tfrac16\) and \(\pi_jp_{j1}=\tfrac16\cdot1=\tfrac16\).

Stationary Does Not Mean Convergent

The degree formula identifies a stationary distribution, not necessarily the limiting distribution of the chain from every initial state. For instance, take the connected graph consisting of one edge between vertices \(1\) and \(2\). Its transition matrix is \(\begin{bmatrix}0&1\\1&0\end{bmatrix}\), and its stationary distribution is \((\tfrac12,\tfrac12)\). Starting at vertex \(1\), the distribution at even times is \((1,0)\) and at odd times is \((0,1)\), so it does not converge. This example is enough to show why stationarity and convergence must not be treated as synonyms; no claim about a limiting distribution is needed for the degree-proportional result.

Common mistake: using a uniform distribution on an irregular graph. On the four-vertex path above, the uniform row vector would be \(\eta=(\tfrac14,\tfrac14,\tfrac14,\tfrac14)\). Its first coordinate after one step is \((\eta P)_1=\eta_2p_{21}=\tfrac14\cdot\tfrac12=\tfrac18\), which is not \(\eta_1=\tfrac14\). Thus \(\eta\) is not stationary. The correction is to weight each vertex by its degree: the path’s stationary mass at an interior vertex is twice its mass at an endpoint, yielding \((\tfrac16,\tfrac13,\tfrac13,\tfrac16)\). On a regular graph, by contrast, all degrees are equal, so the degree-proportional distribution is uniform.

For a finite connected undirected graph with at least two vertices, the calculation can be applied in three checks: confirm the graph’s degrees, normalize those degrees by their sum, then verify that each edge carries equal flow in both directions. The theorem guarantees that this distribution is stationary and unique. If the graph is not connected, the connectedness argument for uniqueness no longer applies: separate components do not exchange probability mass.

Check Your Understanding

Use the definition of the simple random walk and the edge-balance calculation to answer the following.

  1. A path has five vertices and four edges. What are its vertex degrees and its degree-proportional stationary distribution?
  2. For an edge \(\{i,j\}\), calculate \(\pi_i p_{ij}\) using \(\pi_i=d(i)/(2|E|)\). Why does the same value arise in the reverse direction?
  3. What assumption ensures that every degree is positive in the theorem, and why is it needed to define the transition probabilities?
  4. Explain why detailed balance implies stationarity by summing the incoming flows to a fixed vertex.
  5. Give an example of a connected graph whose stationary distribution is uniform, and state the graph property that makes it uniform.