BITS Pilani
BITS Logo
CS G526: Advanced Algorithms and Complexity

Seidel’s APSP Algorithm & The Isolation Lemma

Lecture 15 |2026-09-17
Tulasimohan Molli
BITS Pilani, Hyderabad Campus

Agenda

Part I: Seidel’s Subcubic APSP Algorithm

  1. Algebraic Distance Computation: Standard Matrix Operations over \mathbb{Z}
  2. Giant Leaps: Matrix Squaring Z = A^2 & Graph G'
  3. Base Case D = 2B - A & Distance Halving
  4. The Dichotomy Test: Parity Resolution via X = T \cdot A

Part II: The Isolation Lemma & Parallel Bipartite Matching

  1. The Parallel Matching Bottleneck (\text{NC} vs Sequential Search)
  2. The Isolation Lemma (Mulmuley–Vazirani–Vazirani)
  3. Bipartite Graphs: The Edmonds Matrix & Direct Determinant
  4. Parallel Matching via Matrix Inversion (B^{-1} in \text{RNC}^2)

Siedel’s Algorithm

  • Siedel’s Algorithm
  • Isolation lemma and Paralell algorithms

Subcubic APSP: Seidel’s Algebraic Algorithm

Seidel’s Algorithm: \text{APD}(A) (1995)

  • Input: Adjacency matrix A of a connected, undirected graph G = (V, E) with A_{ii} = 0.
  • Output: All-pairs shortest path distance matrix D.
  • The Core Idea: Square the adjacency matrix to take “giant leaps” across the graph!
  • Step 1: Compute Common Neighbors
    • Fast Matrix Multiply: Z = A^2 in O(n^\omega) time.
    • Z_{i,j} = \sum_k A_{ik} A_{kj} counts the exact number of common neighbors of i and j.
  • If Z_{i,j} > 0, there exists a path of length 2 between i and j.

Building the Giant-Leap Graph G'

Using A and Z, construct graph G' where every edge represents 1 or 2 hops in G:

  • Step 2: Define Adjacency Matrix B B_{i,j} = \begin{cases} 1 & \text{if } i \neq j \text{ and } (A_{i,j} = 1 \text{ or } Z_{i,j} > 0) \\ 0 & \text{otherwise} \end{cases}

  • Geometric Interpretation:

    • Vertices connected in G' were at distance 1 or 2 in original graph G.
  • Key Distance Relation (Distance Halving):

    • If d_G(i,j) is the distance in G, the distance T_{i,j} in G' satisfies: T_{i,j} = \left\lceil \frac{d_G(i,j)}{2} \right\rceil

    • Every recursive step halves the graph’s diameter, yielding depth \lceil \log_2 n \rceil!

Base Case & Recursive Leap

Base Case Check: Diameter \le 2

If B_{i,j} = 1 for all i \neq j (all pairs are \le 2 hops away in G), return directly: D = 2B - A

  • Why D = 2B - A?
    • Adjacent in G (d = 1): B_{ij} = 1, A_{ij} = 1 \implies D_{ij} = 2(1) - 1 = \mathbf{1}.
    • 2 hops in G (d = 2): B_{ij} = 1, A_{ij} = 0 \implies D_{ij} = 2(1) - 0 = \mathbf{2}.
    • Diagonal: 2B_{ii} - A_{ii} = 2(0) - 0 = \mathbf{0}.
  • Recursive Step: If zeroes remain in B, recurse on halved graph: T = \text{APD}(B)

The Dichotomy Test: Parity Resolution

Since T_{u,v} = \lceil d_G(u,v) / 2 \rceil, true distance in G is either 2 T_{u,v} (even) or 2 T_{u,v} - 1 (odd).

  • Neighbor-Sum Matrix: Compute X = T \cdot A, where X_{u,v} = \sum_{k \in N(v)} T_{u,k}.
  • The Parity Duality:
    • Even (d_G(u,v) = 2 T_{u,v}): All neighbors satisfy T_{u,k} \ge T_{u,v} \implies X_{u,v} \ge \text{deg}(v) \cdot T_{u,v}.
    • Odd (d_G(u,v) = 2 T_{u,v} - 1): Predecessor has T_{u,k} = T_{u,v} - 1 \implies X_{u,v} < \text{deg}(v) \cdot T_{u,v}.
  • The Parity Decision: d_G(u,v) = \begin{cases} 2 \cdot T_{u,v} & \text{if } X_{u,v} \ge \text{deg}(v) \cdot T_{u,v} \\ 2 \cdot T_{u,v} - 1 & \text{if } X_{u,v} < \text{deg}(v) \cdot T_{u,v} \end{cases}

Matrix Pipeline in Seidel’s Algorithm

Matrix Dimensions Computation / Operation Purpose / Meaning
A n \times n Given graph adjacency matrix A_{u,v} = 1 if (u,v) \in E, 0 otherwise
Z n \times n Fast Matrix Multiply: Z = A^2 $Z_{u,v} = $ number of length-2 paths
B n \times n Boolean OR: A \lor (Z > 0) Adjacency of squared graph G' (\text{diam} \le \lceil \text{diam}/2 \rceil)
T n \times n Recursive call: T = \text{APD}(B) Shortest distances in G': T_{u,v} = \lceil d_G(u,v)/2 \rceil
X n \times n Fast Matrix Multiply: X = T \cdot A Sum of neighbor distances: X_{u,v} = \sum_{k \in N(v)} T_{u,k}
D n \times n Parity threshold test via X Final distance matrix d_G(u,v) \in \{2T, 2T-1\}

Seidel’s Complexity: Matrix Budget

Work per Recursive Level

At each recursive invocation on graph G:

  1. Z = A^2: One Boolean/integer matrix multiplication \implies O(n^\omega).
  2. X = T \cdot A: One integer matrix multiplication \implies O(n^\omega).
  3. Thresholding & Boolean logic: Entrywise O(n^2) time.
  • Recursion Depth: Diameter is halved at each step: \text{depth} \le \lceil \log_2 n \rceil

  • Overall Time Complexity: T(n) = T(n, \text{diam}/2) + 2 \cdot O(n^\omega) = \mathbf{O(n^\omega \log n)} = \tilde{O}(n^{2.372})

  • Result: Solves All-Pairs Shortest Paths in truly subcubic time!

Isolation lemma and Paralell algorithms

  • Siedel’s Algorithm
  • Isolation lemma and Paralell algorithms

The Parallelization Bottleneck

Can we find a maximum matching in parallel in O(\text{polylog}(n)) time using \text{poly}(n) processors (\text{NC} class)?

  • The Combinatorial Barrier: Edmonds’ blossom augmenting path algorithms are intrinsically sequential (each augmentation depends on the previous).
  • The Algebraic Determinant: Computing the determinant of a numeric matrix is in \text{NC}^2 (via Csanky’s / Berkowitz’s algorithm).
  • The Cancellation Trap:
    • When multiple perfect matchings exist, evaluating the determinant can result in terms cancelling out!
    • The Goal: Force the graph to have a unique minimum-weight perfect matching so that algebraic methods can single it out without cancellation!

The Isolation Lemma

The Isolation Lemma (Mulmuley, Vazirani, Vazirani — 1987)

Let S_1, S_2, \dots, S_k be an arbitrary collection of subsets of a ground set E = \{e_1, \dots, e_m\}. Assign each element e_i a weight w_i \in \{1, 2, \dots, 2m\} chosen independently and uniformly at random. The weight of a subset is w(S) = \sum_{e \in S} w(e).

Then, with probability at least 1/2, there is a unique subset of minimum weight: \Pr\big[\, \text{Unique } S \in \mathcal{F} \text{ minimizes } w(S) \,\big] \ge 1 - \frac{m}{2m} = \frac{1}{2}

  • Remarkable Fact: The number of subsets k can be exponentially large (k = 2^m), yet the weight range is only linear (2m)!

Proof of the Isolation Lemma

For a fixed element x \in E, define the threshold weight \alpha(x): \alpha(x) = \min_{S \in \mathcal{F}, x \notin S} w(S) - \min_{S \in \mathcal{F}, x \in S} \big(w(S) - w(x)\big)

  • Notice that \alpha(x) depends only on the weights of elements other than x!

  • Element x is ambiguous if there exist two min-weight sets S_1, S_2 such that x \in S_1 and x \notin S_2.

  • This happens if and only if w(S_1) = w(S_2), which forces: w(x) = \alpha(x)

  • Since w(x) is chosen uniformly from \{1, \dots, 2m\} independently of \alpha(x): \Pr[w(x) = \alpha(x)] \le \frac{1}{2m}

  • By the Union Bound over all m elements: \Pr[\exists \text{ any ambiguous element}] \le \sum_{x \in E} \frac{1}{2m} = m \cdot \frac{1}{2m} = \frac{1}{2}

  • If no element is ambiguous, the minimum-weight set must be unique! \quad\blacksquare

Bipartite Matching: The Edmonds Matrix

Let G = (U, V, E) be a bipartite graph with |U| = |V| = n, and let m = |E|.

The Bipartite Edmonds Matrix B

Define the n \times n matrix B where each edge (u_i, v_j) \in E is assigned a variable x_{ij}: B_{ij} = \begin{cases} x_{ij} & \text{if } (u_i, v_j) \in E \\ 0 & \text{otherwise} \end{cases}

  • By the Leibniz formula: \det(B) = \sum_{\sigma \in S_n} \text{sgn}(\sigma) \prod_{i=1}^n B_{i, \, \sigma(i)}

  • Exact 1-to-1 Correspondence: Every valid permutation \sigma with \prod_{i=1}^n B_{i, \sigma(i)} \neq 0 is precisely a perfect matching M = \{(u_i, v_{\sigma(i)})\}_{i=1}^n!

  • No Pfaffians or cycle covers needed: The determinant directly sums over perfect matchings \mathcal{M}!

Isolating Bipartite Matchings

Apply the Isolation Lemma to the family of all perfect matchings \mathcal{M}:

  • Assign random integer weights w_{ij} \in \{1, 2, \dots, 2m\} independently to each edge.

  • Substitute x_{ij} = 2^{w_{ij}} into the Edmonds matrix: \det(B) = \sum_{M \in \mathcal{M}} \text{sgn}(M) \prod_{(u_i, v_j) \in M} 2^{w_{ij}} = \sum_{M \in \mathcal{M}} \text{sgn}(M) \, 2^{w(M)}

  • Let W = \min_{M \in \mathcal{M}} w(M). With probability \ge 1/2, min-weight matching M^* is unique: \det(B) = \text{sgn}(M^*) \cdot 2^W + \sum_{M \neq M^*} \text{sgn}(M) \, 2^{w(M)} = 2^W \cdot \big(\text{odd integer}\big) \neq 0

  • Key Fact: The lowest non-zero bit of \det(B) is exactly 2^W!

    • Finding the index of the least significant bit immediately gives the min weight W.

Testing Edge Membership via Matrix Inversion

How do we test whether edge e = (u_i, v_j) belongs to the unique min-weight matching M^*?

  • Edge (u_i, v_j) \in M^* if and only if G \setminus \{u_i, v_j\} has a matching of weight W - w_{ij}: \frac{\det(B_{/\{i, j\}}) \cdot 2^{w_{ij}}}{2^W} \text{ is odd} \quad \big(B_{/\{i,j\}} \text{ deletes row } i, \text{ column } j\big)

  • Cramer’s Rule & The Adjugate Matrix: The sub-determinant \det(B_{/\{i,j\}}) is the (i,j)-cofactor: (B^{-1})_{ji} = \frac{(-1)^{i+j} \det(B_{/\{i, j\}})}{\det(B)}

  • The MVV Parallel Speedup: Instead of computing m separate determinants, compute a single matrix inverse B^{-1} in parallel! (u_i, v_j) \in M^* \iff \frac{(B^{-1})_{ji} \cdot \det(B) \cdot 2^{w_{ij}}}{2^W} \text{ is odd}

  • Parallel Complexity: Inverting an n \times n matrix is in \text{NC}^2 \implies Parallel Bipartite Matching is in \text{RNC}^2!

Concept Check

Answer each question based on today’s concepts:

  1. In Seidel’s algorithm, what is the maximum depth of recursion and why?
  2. If edge weights are chosen from \{1, \dots, 2m\}, why does the minimum-weight matching become unique with probability at least 1/2?
    1. \lceil \log_2 n \rceil levels, because the giant-leap construction B at least halves the graph’s diameter at each step.
    1. By the Isolation Lemma, each edge has at most one “ambiguous” threshold weight (\le 1/(2m)), and union bound over m edges gives \le m/(2m) = 1/2 failure probability.

Next Lecture

Game Theory Foundations & von Neumann’s Minimax Theorem — strategic representations, extensive-form/tree games, the game of NIM, bimatrix games, Nash equilibria, and von Neumann’s Minimax Theorem.