MVV Algorithm for Parallelized Bipartite Matching

There are already many polynomial sequential algorithms that can be used for matching, but we can make use of Polynomial Identity Testing to come up with a randomized, parallelizable algorithm (Mulmuley, Vazirani and Vazirani algorithm)

Edmond’s Matrix

Given a graph G=(L,R,E)G = (L, R, E), we define a matrix XGX_{G} with entries defined as follows.

Xij={xijif exists an edge (i,j),iL,jR0otherwiseX_{ij} = \begin{cases} x_{ij} & \text{if}\ \text{exists an edge } (i, j), i \in L, j \in R \\ 0 & \text{otherwise} \end{cases}

This matrix is known as Edmond’s matrix. xijx_{ij} is not some constant, they are distinct variables (hence there are n2n^{2} variables possible)

We define the determinant of the matrix as

Det(X)=σSnsgn(σ)i[n]xiσ(i)\operatorname{Det}(X) = \sum\limits_{\sigma \in S_{n}} \operatorname{sgn}(\sigma) \prod_{i\in [n]} x_{i \sigma(i)}

Here, σ\sigma is a permutation that belongs to the set SnS_{n}, the set of all permutations of length nn.

When is Det(X)0\text{Det}(X) \neq 0?

If the determinant of the matrix is not 00, then we know that there exists some permutation σSn\sigma \in S_{n} such that each xiσ(i)0x_{i \sigma(i)} \neq 0. Remember that no two terms can cancel each other out since all the variables are distinct, which is why this condition is sufficient.

Theorem - Graph GG has a perfect matching     \iff Det(XG)0\text{Det}(X_{G}) \neq 0

GG has PM     Det(XG)0\implies \text{Det}(X_{G}) \neq 0

Suppose GG has a perfect matching, then we essentially have a bijection mapping every liLl_{i} \in L to a unique riRr_{i}\in R, and bijections can be seen as a permutation, hence we know that

i=1nXiσ(i)=i=1nxiσ(i)\prod_{i=1}^{n} X_{i \sigma(i)} = \prod_{i=1}^{n} x_{i \sigma(i)}

is a non-zero monomial in the polynomial, and since we know that the monomials can’t cancel each other out, we have a non-zero determinant.

GG has PM Det(XG0)\Longleftarrow \text{Det}(X_{G} \neq 0)

Suppose Det(XG)0\text{Det}(X_{G}) \neq 0, this means that there exists at least one permutation σ\sigma such that all terms Xiσ(i)X_{i \sigma(i)} are not 00. This indicates that each vertex liLl_{i} \in L got matched to vvertex rσ(i)Rr_{\sigma(i)} \in R. Since σ\sigma is a bijection, we know that matching is perfect.

Using this theorem, we can come up with a sequential algorithm

Sequential Algorithm for Bipartite Matching

  1. M{}M \leftarrow \{\}
  2. For each e=(i,j)Ee = (i, j) \in E,
    1. G=(L\{i},R\{j},E\{e})G' = (L \backslash \{i\}, R \backslash \{j\}, E \backslash \{e\})
    2. If Det(XG)0\operatorname{Det}(X_{G}) \neq 0
      1. GGG \leftarrow G'
      2. MM{e}M \leftarrow M \cup \{e\}
  3. Return MM

The running time of this algorithm is mm into the time complexity for computing the determinant, O(mn3)O(mn^{3})

Note that depending upon the order of edges we take, we could get different perfect matchings.

Theorem - If AA is an n×nn\times n matrix, then Det(A),adj(A),A1\text{Det}(A), \text{adj}(A), A^{-1} can all be computed in O(log2n)O(\log^{2}n) time over O(n3.5)O(n^{3.5}) processors.

Using this theorem, we devise a parallel randomized algorithm for perfect matching.

Parallel Algorithm for Perfect Matching

Theorem - There is a randomized algorithm that finds a perfect matching in O(log2n)O(\log^{2}n) time using O(mn3.5)O(mn^{3.5}) processors with probability 12\frac{1}{2}.

Key Idea - We randomly assign edge weights in the graph, and show that if a perfect matching exists, there is a unique minimum perfect matching.

Isolation Lemma

Let SS be a finite subset of R\mathbb{R}. Let T1,T2,,TkT_{1}, T_{2}, \dots, T_{k} be some subsets of {1,2,,m}\{1, 2, \dots, m\}. For each i{1,2,,m}i \in \{1, 2, \dots, m\} assign a weight uniformly and randomly from SS. We define the weight of TjT_j as

wt(Tj)=iTjwt(i)\text{wt}(T_{j}) = \sum\limits_{i\in T_{j}} \text{wt}(i)

The Isolation Lemma states that

P[j s.t Tj has unique min wt]1mS\mathbb{P}[\exists j\ \text{s.t}\ T_{j} \text{ has unique min wt}] \geq 1 - \frac{m}{|S|}

Proof
Suppose j,j\exists j, j' such that TjT_{j} and TjT_{j'} attain the minimum weight

This implies that

iTjwt(i)=iTjwt(i)\sum\limits_{i \in T_{j}} \text{wt}(i) = \sum\limits_{i' \in T_{j'}} \text{wt}(i')

Let eTj\Tje \in T_{j} \backslash T_{j'}, we can take wt(e)\text{wt}(e) out to write the above equation as

wt(e)+ie,iTjwt(i)=iTjwt(i)\text{wt}(e) + \sum\limits_{i \neq e, i \in T_{j} }\text{wt}(i) = \sum\limits_{i' \in T_{j'}} \text{wt}(i)

To calculate the probability of having two non minimum matchings when using randomized values, we can use the Principle of Deferred Decisions.
Since we know that no matter what the sum of weights are in Tj\{e},TjT_{j}\backslash \{e\}, T_{j'}, there is at most one value of wt(e)\text{wt}(e) that can satisfy the equation, hence we can say that the probability is upper bounded by 1S\frac{1}{|S|}.

We define a bad case as 2 sets Tj,TjT_{j}, T_{j'} that have the same weight.

We define an event EiE_{i} such that

minj{wt(Tj)iTj}=minj{wt(Tj)i∉Tj}\min_{j}\{\text{wt}(T_{j}) | i \in T_{j}\} = \min_{j'}\{\text{wt}(T_{j'}) | i \not \in T_{j'}\}

If EiE_{i} occurs, it implies there exists two unique matchings that achieve the minimum.

If i=1mEˉi\bigcap_{i = 1}^{m}\bar E_{i} occurs, then \exists a unique minimum wt of TjT_{j}. (Sufficient, but not necessary condition).

P[i=1mEˉi]=1P[i=1mEi]1i=1mP[Ei]1mS\mathbb{P}\left[\bigcap_{i=1}^{m} \bar E_{i}\right] = 1 - \mathbb{P}\left[\bigcup_{i=1}^{m} E_{i}\right] \geq 1 - \sum\limits_{i=1}^{m}\mathbb{P} [E_{i}] \geq 1 - \frac{m}{|S|}

Hence proved.

Different Matrix Definition

Initially, we assign each edge a weight i.u.a.r from SS.
Then, we define a new matrix WW as

Wij={2wt(i,j)if iL,jR,(i,j)E0otherwiseW_{ij} = \begin{cases} 2^{\text{wt}(i, j)} & \text{if } i \in L, j \in R, (i, j) \in E \\ 0 & \text{otherwise} \end{cases}

Now, we’ll get the determinant of this matrix as follows

Det(W)=σSnsgn(σ)i=1nWiσ(i)=σSnsgn(σ)i=1(i,σ(i))Ein2wt(i,σ(i))=σSnσMsgn(σ)2wt(Mσ)\begin{aligned} \text{Det}(W) &= \sum\limits_{\sigma\in S_{n}} \text{sgn}(\sigma) \prod_{i=1}^{n}W_{i\sigma(i)}\\ &= \sum\limits_{\sigma\in S_{n}} \text{sgn}(\sigma) \prod_{\substack{i=1\\(i, \sigma(i)) \in E\\\forall i}}^{n} 2^{\text{wt}(i, \sigma(i))}\\ &= \sum\limits_{\substack{\sigma\in S_{n} \\ \sigma \in M}} \text{sgn}(\sigma) 2^{\text{wt}(M_{\sigma})} \end{aligned}

Where MM is the set of all perfect matchings, and MσM_{\sigma} is the matching resulting from σ\sigma.

If rr is the minimum weight matching, then we know that 2r2^{r} divides Det(W)\text{Det}(W) .

Det(W)=sgn(M1)2wt(M1)+sgn(M2)2wt(M2)++sgn(Mt)2wt(Mt)=2wt(M0)[sgn(M0)+rest]\begin{aligned} \text{Det}(W) &= \text{sgn}(M_{1}) 2^{\text{wt}(M_{1})} + \text{sgn}(M_{2}) 2^{\text{wt}(M_{2})} + \dots + \text{sgn}(M_{t})2^{\text{wt}(M_{t})} \\ &= 2^{\text{wt}(M_{0})} [\text{sgn}(M_{0}) + \text{rest}] \end{aligned}

Where M0M_{0} is the minimum weight matching

Lemma to process edges independently

We denote the matrix where row ii and column jj is removed as W(i,j)W^{(i, j)}.
Let M0M_{0} be the unique minimum weight perfect matching in GG, let r=wt(M0)r = \text{wt}(M_{0}), then

(i,j)M0    Det(W(i,j))2wt(i, j)2r is odd(i, j) \in M_{0} \iff \frac{\text{Det}(W^{(i, j)}) 2^{\text{wt(i, j)}}}{2^{r}} \text{ is odd}

The significance of this lemma is that if we know rr, we can figure out if some edge eEe \in E belongs to the matching independently of the other edges, allowing us to parallelize the processing of edges.

(i,j)M0    Det(W(i,j))2wt(i, j)2r is odd(i, j) \in M_{0} \implies \frac{\text{Det}(W^{(i, j)}) 2^{\text{wt(i, j)}}}{2^{r}} \text{ is odd}

First, we show that if M0M_{0} is the unique minimum weight perfect matching, then Det(W)2wt(M0)\frac{\text{Det}{(W)}}{2^{\text{wt}(M_{0})}} is odd.
We’ve seen earlier that we can write the determinant as

Det(W)=2wt(M0)[sgn(M0)+rest]\begin{aligned} \text{Det}(W) &= 2^{\text{wt}(M_{0})} [\text{sgn}(M_{0}) + \text{rest}] \end{aligned}

we know that sgn(M0)\text{sgn}(M_{0}) is either 1-1 or 11, both of which are odd. We also know that the rest of the terms are all even as they all have the coefficient 2wt(Mi)wt(M0)2^{\text{wt}(M_{i}) - \text{wt}(M_0)} (or is just 0 if σ∉M\sigma \not \in M), and unique minimum weight guarantees wt(Mi)wt(M0)>0\text{wt}(M_{i}) - \text{wt}(M_{0})> 0. Therefore [sgn(M0)+rest][\text{sgn}(M_{0}) + \text{rest}] is odd, hence

Det(W)2wt(M0)\frac{\text{Det}(W)}{2^{\text{wt}(M_{0})}}

is odd.

Now, if we have (i,j)M0(i, j) \in M_{0}, we claim that M0\{(i,j)}M_{0} \backslash \{(i, j)\} forms a unique minimum weight perfect matching for the graph G=(L\{i},R\{j},E)G' =(L\backslash\{i\}, R\backslash\{j\}, E').
This can be proven using proof by contradiction -

  1. If this isn’t the minimum weight matching, say there is some MM' perfect matching for subgraph GG' such that it’s weight is less than that of M0\{(i,j)}M_{0}\backslash\{(i, j)\}, we can get a better minimum perfect matching than M0M_{0} by using M{(i,j)}M' \cup \{(i, j)\}, contradicting that M0M_{0} is the minimum weight PM.
  2. If there doesn’t exist a unique minimum perfect matching, say there’s MM'' such that it has the same weight as M0\{(i,j)}M_{0} \backslash \{(i, j)\}, we can then construct another minimum matching for graph GG, using M{(i,j)}M'' \cup \{(i, j)\}, contradicting the assumption that M0M_{0} is a unique minimum PM.

If the minimum weight matching of GG is 2r2^{r}, then for GG' it’ll be 2rwt(i,j)2^{r - \text{wt}(i, j)}.
Since we know there exists a unique minimum PM for GG', we can use the earlier claim to say that

Det(W(i,j))2rwt(i,j)=Det(W(i,j))2wt(i,j)2r\frac{\text{Det}(W^{(i, j)})}{2^{r - \text{wt}(i,j)}} = \frac{\text{Det}(W^{(i, j)}) 2^{\text{wt}(i,j)}}{2^{r}}

is odd as well.

(i,j)M0Det(W(i,j))2wt(i, j)2r is odd(i, j) \in M_{0} \Longleftarrow \frac{\text{Det}(W^{(i, j)}) 2^{\text{wt(i, j)}}}{2^{r}} \text{ is odd}

We can instead show that if (i,j)∉M0(i, j) \not \in M_{0}, then Det(W(i,j))2wt(i, j)2r\frac{\text{Det}(W^{(i, j)}) 2^{\text{wt(i, j)}}}{2^{r}} is even.

Det(W)=σSnsgn(σ)i=1nWiσ(i)\text{Det}(W) = \sum\limits_{\sigma\in S_{n}} \text{sgn}(\sigma) \prod_{i=1}^{n}W_{i\sigma(i)}

We now break this summation into two terms, the permutations that contain σ(i)=j\sigma(i) = j and those where σ(i)j\sigma(i) \neq j (Signify if that edge is picked or not).

Det(W)=(σsgn(σ)ii2wt(i,σ(i)))2wt(i,j)+(σσ(i)jsgn(σ)2wt(i,σ(i)))\text{Det}(W) = \left(\sum\limits_{\sigma'}\text{sgn}(\sigma') \prod_{i'\neq i}2^{\text{wt}{(i', \sigma(i'))}}\right) 2^{\text{wt}(i, j)} + \left(\sum\limits_{\substack{\sigma\\ \sigma(i) \neq j}}\text{sgn}(\sigma) \prod 2^{\text{wt}(i, \sigma(i))}\right)

Here, σ\sigma' signifies the permutations [n]\{i}[n]\{j}[n]\backslash \{i\} \rightarrow [n] \backslash \{j\}.

The first term essentially corresponds to Det(W(i,j))2wt(i,j)\text{Det}(W^{(i, j)}) 2^{\text{wt}(i, j)}.

Since (i,j)∉M0(i, j) \not \in M_{0}, we know that M0M_{0} will be found in the second term above. Hence, we can rewrite the second term as

2r[sgn(M0)+σσ(i)jσM0sgn(σ)2wt(σ)r]2^{r}[\text{sgn}(M_{0}) + \sum\limits_{\substack{\sigma'\\ \sigma'(i) \neq j\\ \sigma' \neq M_{0}}} \text{sgn}(\sigma') 2^{\text{wt}(\sigma') - r}]

Hence, we can rewrite the formulation of Det(W)\text{Det}(W) along with dividing all the terms to get

Det(W)2r=Det(W(i,j))2wt(i,j)2r+[±1+σσ(i)jσM0sgn(σ)2wt(σ)r]\frac{\text{Det}(W)}{2^{r}} = \frac{\text{Det}(W^{(i,j)})2^{\text{wt}(i, j)}}{2^{r}} + [\pm 1 + \sum\limits_{\substack{\sigma'\\ \sigma'(i) \neq j\\ \sigma' \neq M_{0}}} \text{sgn}(\sigma') 2^{\text{wt}(\sigma') - r}]

We know that the LHS and the second term in the RHS are both odd. Therefore, the first term must be even.

Hence, if (i,j)∉M0(i, j) \not \in M_{0}, then

Det(W(i,j))2wt(i,j)2r\frac{\text{Det}(W^{(i,j)})2^{\text{wt}(i, j)}}{2^{r}}

is even.

We then use this lemma to make the parallel algorithm

Algorithm

  1. Compute Det(W)\text{Det}(W). The determinant is bounded by n!×2max{S}n2nlogn±O(n)×2max{S}nn! \times 2^{\max\{S\} \cdot n} \approx 2^{n \log n \pm O(n)} \times 2^{\max\{S\} \cdot n}. Hence the bit complexity is polynomial as S=O(m)|S| = O(m).
  2. We then binary search on rr, to find the largest value such that 2r2^{r} divides Det(W)\text{Det}(W).
  3. For all edges (i,j)E(i, j) \in E, we parallely and independently
    1. Compute Det(W(i,j))2wt(i,j)2r\frac{\text{Det}(W^{(i,j)})2^{\text{wt}(i, j)}}{2^{r}}
    2. If the result is odd, then (i,j)M0(i, j) \in M_{0}, else not.

We know that each edge requires O(n3.5)O(n^{3.5}) processors to compute the determinant in O(log2n)O(\log^2 n) time, hence we require O(mn3.5)O(mn^{3.5}) processors to compute in O(log2n)O(\log^{2}n) time.

Published Feb 2, 2023