For a Gaussian vector, variables j and k are independent given all the others exactly when θjk = 0 in Θ = Σ−1. Here every edge of a graph gets the same partial correlation ρ (so Θ = I − ρA, with A the adjacency matrix). The precision matrix is as sparse as the graph; the covariance matrix Σ = Θ−1 is zero only between different connected components. In the fitting mode, Algorithm 17.1 finds the maximum-likelihood Σ̂ for the graph: it copies S on the edges and the diagonal and fills the missing edges so that Σ̂−1 has its zeros there.
Θ has unit diagonal, so ρ is minus each edge's entry, and ρ is kept inside the range where Θ is positive definite (1 − ρμ > 0 for every eigenvalue μ of A). Separating sets are found by searching all subsets for the smallest one. Algorithm 17.1: for each node in turn, solve W*11β* = s*12 on its neighbours, pad β with zeros and set w12 = W11β; a sweep visits every node once. Samples are drawn from N(0, Σ) with the seeded generator of the course, and S uses the divisor N.
code/ch17_undirected_graphical_models.py (modified_regression, separates, minimal_separators, partial_correlations).