Matroids and greedy optimality
Recognize hereditary independence and augmentation, prove weighted greedy optimality, and distinguish maximal sets from maximum ones.
On this page
The question for today
What you’ll understand
- Check the independence axioms on a finite set system.
- Use basis exchange to justify descending-weight greedy selection.
- Identify a hereditary system where greedy fails because augmentation fails.
Some problems permit greedy selection for every assignment of weights, not just for one carefully chosen ordering rule. Matroids capture the independence structure behind that phenomenon. A forest can accept another edge without creating a cycle, and a list of vectors can accept another vector without creating a dependence. Their objects differ, but both have enough exchange flexibility to prevent a small maximal independent set from blocking a larger one. That shared structure supports a reusable optimality proof.
Independence is hereditary and augmentable
A finite matroid consists of a ground set E and a family of independent subsets. The empty set is independent, every subset of an independent set is independent, and augmentation holds: if independent A is smaller than independent B, some element of B outside A can be added to A while keeping independence. Heredity alone says deleting constraints is safe. Augmentation is the stronger property that prevents a smaller independent set from being completely stuck while a larger one exists.
A basis is an inclusion-maximal independent subset of the full ground set. Augmentation implies that all bases have the same size, called the rank. Maximal means no individual extension is allowed; maximum means largest size or best weight according to a declared objective. These notions coincide in cardinality for matroid bases, but not for arbitrary hereditary families. Graphic matroids take forests as independent edge sets; vector matroids take linearly independent indexed columns, including distinct indices for repeated equal vectors.
Exchange an optimal basis toward the greedy basis
To maximize basis weight, process elements in nonincreasing weight order and add an element whenever independence is preserved. Continue through all elements, even negative-weight ones if a full basis is required. The exchange proof maintains an optimal basis containing the current greedy prefix. If the next accepted element g is absent from that basis, a basis-exchange consequence lets us replace some element outside the prefix by g while retaining a basis. An earlier accepted element belongs to the preserved prefix. An earlier rejected element is dependent with a subset of that prefix, so it cannot belong to a basis containing the prefix. The removed element must therefore occur later in the ordering, with weight no larger than g's.
The exchanged basis therefore has no smaller total weight, and it contains the extended prefix. Repeating gives an optimal greedy basis. For maximum-weight independent sets without a full-basis requirement, discard negative-weight elements or stop before them; adding a negative element could lower the objective. Nonnegative weights allow extending an optimum to a basis without reducing weight. These variants are easy to conflate, so state whether rank completion is compulsory before describing the algorithm.
A familiar feasible family can fail the axiom
Matchings in an arbitrary graph form a hereditary edge family, but generally not a matroid. On the four-vertex path a−b−c−d, the singleton middle edge is a maximal matching, while the two outer edges form a larger matching. Neither outer edge can augment the singleton because each touches the middle edge. Thus augmentation fails. Assigning the middle edge weight three and each outer edge weight two makes descending-weight greedy earn three while an alternative earns four.
The matroid theorem does not claim every successful greedy algorithm comes from a matroid. Earliest-finish interval scheduling is a different objective-specific exchange argument. Nor does a mathematical independence oracle automatically yield a fast implementation: the number and cost of independence tests matter. For a graphic matroid, disjoint-set structures test whether an edge closes a cycle efficiently, producing Kruskal's minimum-spanning-forest rule with ascending costs, and a spanning tree when the graph is connected. For vector matroids, elimination supplies independence tests whose arithmetic and numerical interpretation must be specified.
Work it through
Select a basis under partition constraints
The ground set is {a,b,c,d}. At most one of {a,b} and at most one of {c,d} may be chosen. Weights are a:7, b:5, c:4, d:6. Find a maximum-weight basis and explain the relevant exchange.
The two disjoint blocks each have capacity one, giving a partition matroid. Every basis contains one element from each block, so its rank is two.
Descending weights are a, d, b, c. Greedy accepts a and d, then rejects b and c because their respective block capacities are already used. Its total weight is thirteen.
Any alternative basis can replace its first-block member by a without affecting the second block, and replace its second-block member by d without affecting the first. Neither exchange decreases weight, directly certifying that no basis beats thirteen.
The maximum-weight basis is {a,d}, of weight 13. The argument uses independent block capacities; it does not extend unchanged to overlapping arbitrary constraints.
The living notebook
Explore the model
Interactive lab · matrix
Recognize a tiny vector-matroid basis
Pause and reset, then set both controls to diagonal scale a = 1 and shear b = 0. Predict two independent coordinate columns and determinant one. For a fresh comparison, pause and reset, then set a = 0.25 and b = 2; inspect the skewed square and determinant 0.25. The two columns remain independent because every supported a is positive, despite worse conditioning. The instrument shows only this two-column family, not weight sorting, arbitrary independence tests, or a matroid greedy solver.
- Area scale · det A
- 1.4
- Singular values · σmax, σmin
- 1.597, 0.876
- Condition number · κ₂(A)
- 1.823
The selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forExact independence and numerical conditioning are distinct; the supported triangular matrices always define a two-element basis.
Pause & reason
Check your understanding
Your turn
Try it yourself
A rank-two uniform matroid permits any subset of {u,v,w} with at most two elements. Weights are 5,−1,−4. Compare the maximum-weight basis with the maximum-weight independent set, and explain the stopping rule difference.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
A basis must have rank two, while an independent set may have fewer elements.
Compare with the solution
The best basis is {u,v}, with weight 5−1 = 4; the other bases have weights one and minus five. The best independent set is {u}, with weight five, because every additional element has negative weight. Descending greedy must continue until rank two for the basis objective, accepting v despite its negative weight. For the unrestricted independent-set objective it should skip negative elements. The matroid axioms guarantee the exchange structure, but they do not make these two optimization specifications identical.
Keep the idea
Take it with you
- Matroid independence combines empty-set, hereditary, and augmentation axioms.
- Greedy weight optimality follows from feasible exchanges, with basis and arbitrary-set objectives distinguished.
- Matchings demonstrate that a hereditary system need not be a matroid.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.