Skip to main content

Section 8.1 Definition, Examples and Greedy Algorithms

In this course, we have frequently shifted our focus between presenting bespoke algorithms to solve individual discrete optimization problems and developing broader and more abstract frameworks which can be adapted to solve large classes of problems simultaneously. Examples of the former include Dijkstra’s Algorithm, the Hungarian Algorithm and the Gale–Shapley Algorithm, whereas linear and semi-definite programming are examples of the latter. In this chapter, we explore the broad concept of a matroid which unifies some seemingly disparate notions such as linear independence of vectors and spanning trees in graphs. The definition is somewhat technical, but it should become clearer after seeing a few examples and gaining familiarity with the terminology. Recall that, for a set \(X\text{,}\) we let \(2^X\) denote the collection of all subsets of \(X\text{.}\)

Definition 8.1.1. Matroid.

A matroid is a pair \(M=(X,\mathcal{I})\) where \(X\) is a finite set and \(\mathcal{I}\subseteq 2^X\) such that
  1. \(\emptyset\in\mathcal{I}\text{.}\)
  2. If \(Y\in \mathcal{I}\) and \(Z\subseteq Y\text{,}\) then \(Z\in\mathcal{I}\text{.}\)
  3. If \(Y,Z\in\mathcal{I}\) such that \(|Y|<|Z|\text{,}\) then there exists \(z\in Z\setminus Y\) such that \(Y\cup \{z\}\in\mathcal{I}\text{.}\)
The set \(X\) is called the ground set and an element of \(\mathcal{I}\) is said to be independent and elements of \(2^X\setminus\mathcal{I}\) are dependent.
The first two properties of a matroid are fairly standard and are satisfied by many objects that we are interested in, such as stable sets, matchings, etc. The third condition is the one that really sets apart a matroid from other combinatorial structures. The terminology of independent/dependent is most likely due to the following motivating example.

Example 8.1.2. Linear Matroid.

Let \(X\) be a finite set of vectors in a vector space, and let \(\mathcal{I}\) be the collection of all subsets of \(X\) of linearly independent vectors. The first two properties of a matroid clearly hold. For the third, we know from linear algebra that if \(Y\) and \(Z\) are linearly independent sets of vectors with \(|Y|<|Z|\text{,}\) then the dimension of \(\span(Z)\) is greater than the dimension of \(\span(Y)\text{.}\) So, there exists a vector in \(z\in Z\) that is not contained in \(\span(Y)\text{,}\) and so \(Y\cup \{z\}\) is linearly independent. So, the third property holds as well. A matroid \((X,\mathcal{I})\) of this type is called a linear matroid.
Continuing with the linear algebraic analogies, given a matroid \(M=(X,\mathcal{I})\) and a set \(Y\subseteq X\text{,}\) a basis for \(Y\) is an set that is maximal subject to being independent and satisfying \(B\subseteq Y\text{.}\) As we shall see in a moment, any two bases for a set \(Y\) must have the same cardinality. This leads us to the definition of the rank of a set \(Y\text{,}\) written \(r_M(Y)\text{,}\) which is the cardinality any of its bases. A basis of \(X\) is just called a basis and the rank of \(X\) is sometimes called the rank of \(M\) and denoted \(r(M)\text{.}\)

Proof.

Another key concept in matroid theory is the notion of a circuit. A circuit in a matroid \((X,\mathcal{I})\) is a minimally dependent set \(C\text{.}\) That is, it is a set \(C\subseteq X\) such that \(C\notin\mathcal{I}\) and \(S\in\mathcal{I}\) for all \(S\subsetneq C\text{.}\) Here is a very basic property of bases circuits. Given a set \(X\text{,}\) an antichain is a collection \(\mathcal{A}\subseteq 2^X\) such that there does not exist \(A,B\in\mathcal{A}\) with \(A\subsetneq B\text{.}\)

Proof.

This just follows from the fact that bases are maximal independent sets (and therefore cannot be contained in a larger independent set) and circuits are minimal non-independent sets (and therefore cannot contain a smaller dependent set).
Next, let us describe another important example of a matroid coming from graph theory.

Example 8.1.5. Graphic Matroid.

Recall that a forest is a graph without any cycles (i.e. an acyclic graph). A spanning forest in a graph \(G\) is a subgraph \(F\) of \(G\) such that \(V(F)=V(G)\) and \(F\) is a forest. A tree is a forest that is connected and a spanning tree is a spanning forest that is connected. Every connected graph has a spanning tree.
Let \(G\) be a multigraph (which just means that each edge can appear multiple times), define \(X=E(G)\) and take \(\mathcal{I}\) to be the collection of all subsets \(Y\subseteq E(G)\) such that the graph \((V(G),Y)\) is a spanning forest of \(G\text{.}\) As a slight abuse of terminology, we will often identify a set \(Y\subseteq E(G)\) with the graph \((V(G),Y)\text{.}\) In this language, \(\mathcal{I}\) is the collection of all subgraphs of \(G\) which do not contain a cycle. We claim that this is a matroid. As usual, the first two properties in Definition 8.1.1 hold trivially. Now, let’s take two edge sets \(Y\) and \(Z\) of forests in \(G\) and suppose that \(|Y|< |Z|\text{.}\) Then \(Y\) has precisely \(|V(G)|-|Y|\) components which is more than the \(|V(G)|-|Z|\) components of \(Z\text{.}\) So, one of the edges of \(Z\) must have its endpoints in two different components of \(Y\text{.}\) Adding this edge to \(Y\) does not create a cycle; therefore, the third property holds. Such a matroid is called a graphic matroid or the cycle matroid of \(G\text{.}\)
Now, as an exercise, it is worth thinking about the following questions: What are the bases of a graphic matroid? What are the circuits?

Subsection 8.1.1 Matroids and Greedy Algorithms

When trying to solve any discrete optimization problem, perhaps the simplest strategy is the so called greedy algorithm. Specifically, for a pair \((X,\mathcal{I})\) satisfying the first two properties of Definition 8.1.1 and a weight function \(w:X\to[0,\infty)\text{,}\) suppose that we wish to choose a set \(Y\in\mathcal{I}\) such that \(w(Y):=\sum_{y\in Y}w(Y)\) is maximum. A natural approach is to start by taking the element \(y_1\) of \(X\) of maximum weight, followed by the element of \(X\setminus\{y_1\}\) of maximum weight subject to the constraint that \(\{y_1,y_2\}\in\mathcal{I}\text{,}\) and so on, until we reach a maximal element of \(\mathcal{I}\text{.}\) This is obviously a simplistic approach that will fail to find the optimal solution for most optimization problems (e.g., consider any problem that we have studied in this course so far). However, as we prove next, if \((X,\mathcal{I})\) is a matroid, then the greedy algorithm alert works. Moreover, whenever it is not a matroid, there exists a weight function for which the greedy algorithm fails to find the optimal solution. So, matroids are exactly the structures on which the greedy algorithm always succeeds.

Proof.

First, suppose that \((X,\mathcal{I})\) is a matroid. Clearly, since the weight function is non-negative, the optimum is achieved by a maximum weight basis. We prove that, at every stage of the algorithm, if \(Y\) is the set of points chosen so far, then there exists a basis \(B\) of maximum weight such that \(Y\subseteq B\text{.}\) This is certainly true at the beginning of the algorithm when \(Y=\emptyset\text{.}\) Now, suppose that it is true up to a certain stage, let \(Y\) be the set of points chosen so far, and let \(x\) be the next point to be added to \(Y\text{.}\) Note that, by definition of the greedy algorithm, \(x\) is a point such that \(Y\cup\{x\}\) is independent and the weight of \(x\) is maximized subject to this. Since the property holds so far, there exists a basis \(B\) of maximum weight containing \(Y\text{.}\) If \(x\in B\text{,}\) then we are happy. If not, then, by Property 3, we can continue to add elements from \(B\) to \(Y\cup\{x\}\) while staying independent until we reach an independent set \(B'\) of the same cardinality as \(B\text{.}\) Since \(x\) is the only non-element of \(B\) added during this construction, we have \(B'=(B\setminus\{z\})\cup\{x\}\) for some \(z\in B\text{.}\) However, recall that the greedy algorithm decided to add \(x\) to \(Y\) rather than \(z\text{,}\) despite the fact that \(Y\cup\{z\}\subseteq B\) is independent, and so we must have \(w(x)\geq w(z)\text{.}\) This means that \(w(B')=w(B)-w(z)+w(x)\geq w(B)\) and so, since \(B\) is a maximum weight basis, so is \(B'\text{.}\) Thus, at every stage, the set of points selected is contained in a maximum weight basis and so this is true when the algorithm terminates.
Now, suppose that \((X,\mathcal{I})\) is not a matroid and let \(Y,Z\in\mathcal{I}\) such that \(|Y|<|Z|\) and there does not exist \(z\in Z\) such that \(Y\cup\{z\}\in\mathcal{I}\text{.}\) We would like to set up the weight function in such a way that the best strategy would be to select all of the elements of \(Z\) but, unfortunately, the greedy algorithm is tricked into choosing the elements of \(Y\text{.}\) For this, we pick \(\varepsilon>0\) to be a small constant to be chosen later and define
\begin{equation*} w(x):=\begin{cases} 1+\varepsilon \amp \text{if }x\in Y,\\ 1\amp \text{if }x\in Z\setminus Y,\\ 0 \amp \text{otherwise}.\end{cases} \end{equation*}
Clearly, in the first \(|Y|\) steps, the greedy algorithm will simply select the elements of \(Y\) one by one. Note that, throughout these steps, the set of points selected so far remains a subset of \(Y\) and so it is in \(\mathcal{I}\) by Property 2. After this stage, the algorithm may be able to select additional points of weight zero but, by our assumption on \(Z\text{,}\) it cannot add any points from \(Z\setminus Y\text{.}\) So, it ends up with a final weight of \((1+\varepsilon)|Y|\text{.}\) However, the set \(Z\) certifies that there exists a set in \(\mathcal{I}\) of weight at least \(|Z|\text{.}\) So, since \(|Z|> |Y|\text{,}\) if \(\varepsilon\) is small enough, then we get that the greedy algorithm fails to find the optimal solution to the problem.
The greedy algorithm in the previous theorem may be simplistic, but it allows us to solve some very natural optimization problems. For example, consider the following.

Problem 8.1.7. Minimum Weight Spanning Tree Problem.

For this problem, the input is a connected graph \(G\) and a weight function \(w:E(G)\to\mathbb{R}\text{,}\) and the goal is to obtain a spanning tree in \(G\) of minimum weight.
By applying Theorem 8.1.6 to a graphic matroid, then it is clear that we can find the maximum weight of a spanning tree greedily. By multiplying each weight by \(-1\text{,}\) this gives us a greedy algorithm for finding the minimum weight spanning tree as well. Specifically, the algorithm sequentially chooses an edge of minimum weight subject to the condition that it does not create a cycle. This algorithm is normally referred to as Kruskal’s Algorithm.

Subsection 8.1.2 Further Examples of Matroids and their Duals

We close this section with a few special classes of matroids to provide context and give you some examples to play with. Also, at the end of the section, we introduce the concept of the “dual” of a matroid which is useful for generating even more examples.

Example 8.1.8. Uniform Matroid.

A uniform matroid is a pair \((X,\mathcal{I})\) where, for some \(r\geq1\text{,}\) the collection \(\mathcal{I}\) consists of all subsets of \(X\) of cardinality at most \(r\text{.}\) It is easy to see that this is a matroid. When \(|X|=n\text{,}\) this matroid is often denoted by \(U_n^r\text{.}\)
Now, let’s think about uniform matroids. What are the bases? What are the circuits?

Example 8.1.9. Transversal Matroid.

Let \(X_1,\dots,X_m\) be (not necessarily disjoint) subsets of a set \(X\text{.}\) A partial transversal for \(X_1,\dots,X_m\) is a set \(Y\subseteq X\) with the property that there exists an injective function \(f:Y\to \{1,\dots,m\}\) such that \(y\in X_{f(y)}\) for all \(y\in Y\text{.}\) Note that a partial transversal of cardinality \(m\) is equivalent to a system of distinct representatives; c.f. Exercise 9. The pair \((X,\mathcal{I})\) where \(\mathcal{I}\) is the set of all partial transversals for \(X_1,\dots,X_m\) is called a transversal matroid. Proving that transversal matroids are, indeed, matroids is left as an exercise (Exercise 4).
Now, let’s think about transversal matroids. What are the bases? What are the circuits?

Example 8.1.10. Partition Matroid.

A partition matroid is a transversal matroid defined in terms of sets \(X_1,\dots,X_m\) which are disjoint.
Now, let’s think about partition matroids. What are the bases? What are the circuits?
To generate further examples of matroids from those described above, it is useful to introduce the concept of the “dual” of a matroid.

Definition 8.1.11. Dual of a Matroid.

Given a matroid \(M=(X,\mathcal{I})\text{,}\) the dual of \(M\text{,}\) denoted \(M^*=(X,\mathcal{I}^*)\text{,}\) is defined by letting \(\mathcal{I}^*\) be the collection of \(Y\subseteq X\) such that \(Y\) is disjoint from a basis of \(M\text{.}\)
The following lemma will be proven in the next section.
An important class of matroids that come from taking duals are the co-graphic matroids.

Example 8.1.13. Cographic Matroid.

The dual of a graphic matroid is called a cographic matroid, or the cocycle matroid of the underlying graph \(G\text{.}\)
Now, let’s think about cographic matroids. What are the bases? What are the circuits?

Subsection 8.1.3 Matroid Minors

We close this section with a few basic definitions which allow one to start with one matroid and obtain smaller matroids based on it.

Definition 8.1.14. Matroid Restriction.

Given a matroid \(M=(X,\mathcal{I})\) and a set \(S\subseteq X\text{,}\) the restriction of \(M\) to \(S\) is \(M\mid S:=(S,\{Y\in\mathcal{I}: Y\subseteq S\})\text{.}\)

Definition 8.1.15. Matroid Retraction.

Given a matroid \(M=(X,\mathcal{I})\) and \(Y\in\mathcal{I}\text{,}\) the contraction of \(M\) by \(Y\) is \(M/Y:=(X\setminus Y,\{Z\in\mathcal{I}: Y\cup Z\in\mathcal{I}\})\text{.}\)
It is easily verified that restrictions and retractions of matroids are matroids. A matroid \(M'\) is called a minor of \(M\) if it can be obtained from \(M\) by applying restriction and retraction operations. Matroid minors are closely related to graph minors. In graph theory, a minor of a graph \(G\) is any graph \(H\) that can be obtained from \(G\) by deleting vertices and edges and contracting edges (i.e. pulling the endpoints of an edge together and then deleting the edge).
Here is a YouTube video related to this section: