    # A note on Cunningham's algorithm for matroid intersection

In the matroid intersection problem, we are given two matroids of rank r on a common ground set E of n elements and the goal is to find the maximum set that is independent in both matroids. In this note, we show that Cunningham's algorithm for matroid intersection can be implemented to use O(nr^2(r)) independent oracle calls.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Consider two matroids and with rank functions . Let and be the maximum size of an independent set of either matroids. The goal of the matroid intersection problem is to find the maximum set . Let be the running time of the independent oracle for either matroid. We would like an algorithm that makes as few calls to the independent oracle as possible.

A basic version of Cunningham’s algorithm  is as follows. We start with an empty solution and iteratively increase its size by finding augmenting paths. For any , an exchange graph is the directed bipartite graph with bipartition and such that is an arc if and is an arc if . Define be the set of sources and be the set of sinks.

The algorithm finds a shortest path from and and replace with (the symmetric difference between and ).

The sets and can be found in time . If then we can simply add those elements to . Thus, we focus on the case . In this case, the running time of the iteration depends on the length of the shortest path, which is bounded by the following result of Cunningham.

###### Lemma 1 ().

Let be the maximum size of a common independent set and let be a common independent set that is not maximum. There exists an augmenting path of length at most .

It is usually stated that a more sophisticated version of Cunningham’s algorithm uses oracle calls. In this note, we will show that even the basic version can be implemented using oracle calls.

## 2 Implementation of Cunningham’s algorithm

In this section we describe an implementation of Cunningham’s algorithm. We find a shortest augmenting path using BFS from . The algorithm constructs the graph adaptively as needed for BFS. In every step, given the set of vertices at distance from the sources, the algorithm needs to find their neighbors that are not reachable before. Those neighbors will be all elements at distance from the sources. Let and be the elements that are reachable so far. Consider 2 cases depending on the parity of .

### Case 1.

Distance is even. Consider a vertex . If then the algorithm has found a path from to . If not, we need to find .

We describe an algorithm for finding in time . Initialize . Consider an ordering of such that form a prefix of the ordering. We use binary search to find the minimum such that . If then algorithm finishes since we have found all elements of the unique circuit of . If not, it must be the case that belongs to the unique circuit of and it is an element in . Update and then swap with . Repeat this algorithm until all elements of are found.

### Case 2.

Distance

is odd. We need to find

for some . We describe an algorithm for finding in time . For each element , we check if . If so, because the unique circuit of contains some element in . In fact, one can find one such that by binary search: we find the minimum such that the union of and the first elements of is not in . The element we are looking for is the th element in .

###### Claim 2.

The running time of the algorithm is .

###### Proof.

Next we analyze the running time of the whole algorithm across all iterations of BFS. In case 1, each element in can be in at most once when its status changes from unreachable to reachable. Thus, the total running time of case 1 is . The running time of case 2 depends on the length of the shortest path. If the length of the shortest path is , the total running time of case 2 is .

By the bound on the length of the shortest augmenting path mentioned above, the total length of the augmenting paths is .

Thus, the total running time is . ∎

## References

•  William H Cunningham. Improved bounds for matroid partition and intersection algorithms. SIAM Journal on Computing, 15(4):948–957, 1986.