How to sample connected K-partitions of a graph

Marina MeilaarXiv 2018

Abstract

Sampling connected $K$-partitions—dividing a graph into $K$ connected components—is a computationally difficult task. This paper introduces a simple algorithm that leverages spanning trees to generate valid partitions. While the sampling is non-uniform, the authors derive a closed-form equation to calculate the exact probability of any sampled partition using the Matrix Tree Theorem and Laplacian matrices.

Introduction

Graph partitioning is a fundamental problem in network analysis and computer science. A connected $K$-partition requires dividing the vertices of an undirected graph $G$ into $K$ disjoint sets such that each set induces a connected subgraph. Because counting these partitions is #P-complete, uniform sampling is notoriously difficult. This paper proposes an efficient alternative: a sampling method with mathematically tractable, albeit non-uniform, probabilities.

The Sampling Algorithm

The proposed algorithm, SampleConnectedPartition(K, G), consists of two primary steps:

  1. Sample a Spanning Tree: Select a spanning tree $T$ from the graph $G$ uniformly at random. This can be achieved by assigning random weights to edges and computing the Minimum Spanning Tree (MST).
  2. Edge Removal: Randomly remove $K-1$ edges from the sampled spanning tree $T$ without replacement.

The resulting $K$ disconnected components of the tree define the clusters of the partition. Because every connected partition can be represented as a subset of edges in at least one spanning tree, this method is guaranteed to cover the entire space of valid partitions.

Mathematical Foundation

To determine the probability of sampling a specific partition, the author utilizes Tutte’s Matrix Tree Theorem. This theorem relates the number of spanning trees in a graph to the determinant of a minor of its Laplacian matrix $L(G)$. The Laplacian is defined as $L = D - A$, where $D$ is the degree matrix and $A$ is the adjacency matrix.

The Laplacian matrix $L(G)$ for the 10-node toy graph.

By contracting the nodes within each cluster into "super-nodes," the author constructs a multigraph. The sampling probability then becomes a function of the spanning tree counts of the original graph, the individual clusters, and this contracted multigraph.

Closed-Form Probability

The core contribution of the paper is the derivation of the exact probability $P(U_{1:K})$ for any specific partition $U_{1:K}$:

$$P(U_{1:K}) = \frac{t(M(G, U_{1:K})) \prod_{k=1}^K t(U_k)}{\binom{n-1}{K-1} t(G)}$$

Where:

  • $t(X)$ is the number of spanning trees in subgraph $X$.
  • $M(G, U_{1:K})$ is the contracted multigraph formed by the partition.
  • $n$ is the number of vertices in $G$.

Demonstrative Example

The author demonstrates the calculation using a synthetic 10-node graph. The adjacency matrix defines the connectivity of this toy model.

Adjacency matrix of the 10-node graph used for probability calculations.

For a specific 3-partition, the author computes the determinants of the relevant Laplacian minors to find that the sampling probability is exactly 0.0070. This demonstrates that while the algorithm is non-uniform, its bias is fully transparent and calculable.

Discussion and Limitations

The primary advantage of this method is its simplicity and the existence of a closed-form probability. This makes it a powerful candidate for a proposal distribution in Metropolis-Hastings MCMC algorithms, where the known probability can be used to correct for the sampling bias and achieve a truly uniform distribution.

However, challenges remain regarding computational scaling. While calculating determinants is polynomial ($O(n^3)$), the overhead may become significant for massive graphs with millions of nodes. Additionally, the non-uniform nature of the raw output means it cannot be used directly for applications requiring strict uniformity without further statistical adjustment.

Summary updated

Abstract

A connected undirected graph $G=(V,E)$ is given. This paper presents an algorithm that samples (non-uniformly) a $K$ partition $U_1,\ldots U_K$ of the graph nodes $V$, such that the subgraph induced by each $U_k$, with $k=1:K$, is connected. Moreover, the probability induced by the algorithm over the set ${\mathcal C}_K$ of all such partitions is obtained in closed form.
BibTeX
@misc{meila2018how,
  author = {Marina Meila},
  title = {{How to sample connected K-partitions of a graph}},
  year = {2018},
  eprint = {1808.00050},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1808.00050},
}
Figure