Introduction
Matroid is an abstract algebraic structure proposed by Hassler Whitney in 1935 to unify and generalize the concept of independence, such as linear independence in linear algebra and acyclicity in graph theory.
Matroids provide a powerful theoretical tool for optimization problems involving independence. They are widely used in combinatorics, graph theory, and algorithm design, especially by providing mathematical foundations for optimization methods such as greedy algorithms.
Definition
Matroid
A matroid can be represented as , where:
-
is a finite set called the ground set.
-
is a family of subsets of called the family of independent sets; its members are called independent sets. It has the following three properties:
-
Non-emptiness: The empty set is independent, that is, .
-
Hereditary property: Every subset of an independent set is independent. If , then for every , we have .
-
Augmentation property: If and , then there exists such that .
-
A structure of the form that satisfies these three properties is called a matroid.
Basis
A basis is a maximal independent set in a matroid, that is, an independent set to which no element can be added while preserving independence. The collection of all bases is called the family of bases, denoted by .
Properties:
-
Equal cardinality: All bases have the same size, called the rank of the matroid.
-
Augmentation property: Any independent set can be extended to a basis by adding elements from a basis.
Circuit
A circuit is a minimal dependent set in a matroid: all its proper subsets are independent, while the set itself is not independent. No two circuits contain one another.
Rank
The rank function maps subsets of the ground set to non-negative integers. For any , is defined as the size of the largest independent set in , namely
Properties:
-
Non-negativity: For any , .
-
Monotonicity: If , then .
-
Submodularity: For any , .
Typical Examples
1. Uniform Matroid
Definition: Given a ground set and a non-negative integer , the family of independent sets of the uniform matroid consists of all subsets of size at most , written as
-
Bases: All subsets of size .
-
Circuits: All subsets of size .
-
Rank: , meaning that an independent set can contain at most elements.
2. Graphical Matroid
Definition: Given an undirected graph , the ground set of the graphical matroid is the edge set , and its family of independent sets consists of all edge sets containing no cycle, namely all forests.
-
Bases: Spanning trees of the graph (when the graph is connected). A spanning tree is a maximal independent set: no edge can be added without creating a cycle.
-
Circuits: Simple cycles in the graph. Removing any edge from a cycle leaves an independent set.
-
Rank: , where is the number of connected components of the graph. For a connected undirected graph, its rank equals the number of vertices minus one, namely .
3. Linear Matroid
Definition: A linear matroid is based on a vector space. Given a vector space , the ground set is a finite collection of vectors in , and its family of independent sets consists of all subsets of that are linearly independent.
-
Bases: Maximal linearly independent sets, whose size equals the dimension of the vector space.
-
Circuits: Minimal linearly dependent sets of vectors; every proper subset is independent, while the set itself is linearly dependent.
-
Rank: The rank of a linear matroid is , namely the dimension of the vector space. The size of an independent set cannot exceed the dimension of the vector space.
4. Partition Matroid
Definition: Partition the ground set into disjoint subsets , and specify for each subset a non-negative integer . The family of independent sets of the partition matroid consists of subsets that select at most elements from each part, written as
-
Bases: An independent set satisfying is a basis of the partition matroid. Each basis selects exactly elements from each subset.
-
Circuits: A circuit of a partition matroid is a minimal dependent set, namely a set containing at least one subset with more than elements.
-
Rank: The rank of a partition matroid is , meaning that the largest independent set has size equal to the sum of the maximum permitted numbers of elements selected from the subsets.
5. Colored Matroid
Definition: A colored matroid is a special form of partition matroid in which every element is assigned a color. Given a ground set and a color set , each element is associated with a color . The independent sets of a colored matroid must satisfy not only the independence condition of an ordinary matroid but also color-specific restrictions, such as selecting at most a certain number of elements of the same color.
-
Bases: Maximal independent sets that satisfy the color restrictions and independence conditions.
-
Circuits: Minimal dependent sets containing at least one set of elements that violates independence or a color restriction.
-
Rank: The rank of a colored matroid is the size of the largest independent set satisfying the color restrictions. It depends both on the structure of the matroid and on the specific color restrictions.
Constructions and Operations
Dual
Given a matroid , its dual matroid is defined by
Properties:
-
Bases: The bases of the dual matroid are the complements of the bases of in the ground set . In other words, if is a basis of , then is a basis of .
-
Rank function: The rank function of the dual matroid is , where is a subset of . Thus, the rank of the dual matroid can be computed from the size of the ground set, the rank of the original matroid, and the rank after removing from the ground set.
-
Involution: The dual of the dual matroid is the original matroid, that is, .
Example:
For an undirected graph , the graphical matroid has dual , which is the matroid formed by the cuts of the graph. The bases of are the spanning trees of the graph, while the bases of its dual are the complements of those spanning trees. The circuits of the dual are the minimal cuts of the graph, namely the minimal edge sets whose removal separates the graph into two disconnected parts.
For example, consider a simple triangle graph with edge set . The bases of the graphical matroid are sets of two edges, such as , while the bases of the dual matroid are singleton edge sets, such as . The circuits of are sets of two edges (that is, minimal cuts, such as ), because removing either edge separates the graph into two connected components.
Deletion and Contraction
Deletion:
For , the matroid after deleting gives a new matroid , whose family of independent sets is defined as
The deletion operation can be understood as removing some elements from the matroid and retaining the independent sets formed by the remaining elements. It preserves the original independence relation while removing those elements.
Contraction:
For , the matroid after contracting gives a matroid , whose family of independent sets is defined as
The contraction operation can be understood as contracting the elements of and considering independent sets formed by the remaining elements together with a basis of . The result of contraction depends on the basis of ; the contracted independent sets are effectively obtained by reducing higher-rank subsets of the original matroid.
Example — Graphical Matroid:
-
Deletion: In a graphical matroid, deletion means removing some edges from the graph. After deleting an edge from a graph , consider the independent sets formed by the remaining edges, namely edge sets containing no cycle. For example, deleting one edge from a triangle leaves two edges that still form a forest.
-
Contraction: Contraction turns an edge into a vertex. In a graphical matroid, contracting an edge is equivalent to merging its two endpoints into one vertex and deleting the edge; after the merge, the other edges in the graph can still form independent sets. For example, contracting any edge in a triangle merges two vertices into one, and the remaining two edges form a new matroid.
Matroids and Greedy Algorithms
Problem Statement:
One application of matroids is solving optimization problems with greedy algorithms. Specifically, given a matroid , where is the ground set and is the family of independent sets, assign each element a positive integer weight and seek an independent set of maximum weight, formalized as
Clearly, a maximum-weight independent set must be maximal. If an independent set is not maximal, there is an element that can be added to , namely ; since , adding it increases the weight, so cannot be a maximum-weight independent set.
Steps
The greedy algorithm for finding a maximum-weight independent set proceeds as follows:
- Sort elements: Sort the ground set by weight in descending order, calling the resulting sequence .
- Initialize: Set the independent set .
- Build the independent set: Consider the sorted elements in order. If , update .
- Output: The final set is a maximum-weight independent set.
Complexity Analysis:
Let be the size of the ground set, and let denote the complexity of checking whether a set is independent. The time complexity of the greedy algorithm is
Here, is the complexity of sorting, and is the complexity of checking independence one element at a time.
Note
- In a graphical matroid, a disjoint-set union can efficiently detect whether a cycle is formed, making close to constant time.
- In a linear matroid, checking independence usually involves matrix operations, whose complexity depends on the specific implementation.
Correctness Proof:
Let be a matroid, and let be an independent set, with a subset of some maximum-weight independent set . Define , the set of all elements that can be added to while keeping independent.
Let be the maximum-weight element in . Then is also a subset of some maximum-weight independent set, as follows:
Suppose that is not a subset of any maximum-weight independent set. Then there is a maximum-weight independent set with .
Since , by the augmentation property of the matroid, there exists such that .
Using the augmentation property, repeatedly add to , eventually constructing a new independent set with .
Let . Then and . Since is the maximum-weight element in , we have .
Therefore, , and:
- If , then is not a maximum-weight independent set, contradicting the assumption.
- If , then is a maximum-weight independent set and is its subset, contradicting the assumption that is not a subset of any maximum-weight independent set.
Thus the assumption is false: must be a subset of some maximum-weight independent set. Therefore, by repeatedly applying the greedy strategy, we eventually find a maximum-weight independent set.
Example
Minimum Spanning Tree:
Given a connected undirected graph in which every edge has weight , the goal is to find a spanning tree containing all vertices with minimum total weight.
Constructing the Matroid:
To formulate the minimum spanning tree problem as a matroid problem, construct the graphical matroid :
- Ground set: , namely all edges of the graph.
- Family of independent sets: consists of all edge sets containing no cycle (that is, all forests).
Greedy Algorithm:
In the graphical matroid framework, Kruskal's algorithm is a typical matroid-theoretic greedy algorithm for constructing a minimum spanning tree. Although Prim's algorithm is also an effective greedy algorithm that finds a minimum spanning tree, it does not rely strictly on matroid greediness. Therefore, in discussions of matroid theory, Kruskal's algorithm is the primary example of a matroid greedy algorithm.
-
Kruskal's algorithm:
- Sort edges: Sort all edges in ascending order of weight.
- Select incrementally: Select edges in increasing order of weight; if adding an edge does not create a cycle, add it to the spanning tree.
- Termination condition: Repeat the process until the spanning tree contains edges.
-
Prim's algorithm:
- Principle: Starting from a vertex, Prim's algorithm gradually expands the spanning tree, each time selecting the minimum-weight edge connecting a vertex inside the tree to one outside it.
- Although Prim's algorithm is also greedy, its selection strategy differs from that of other greedy algorithms based on the augmentation property of matroids. Therefore, in the strict sense of matroid theory, Prim's algorithm is not considered a typical matroid greedy algorithm.
Matroid Intersection
For two matroids defined on the same ground set , namely and , if satisfies the three properties of a matroid family of independent sets, then is called the intersection of and .
Note: The intersection of two arbitrary matroids is not necessarily a matroid. It forms a matroid only when the intersection of their independent-set families satisfies the three properties in the definition of a matroid family of independent sets.
Problem Statement
- Maximum independent set: Find an independent set of maximum cardinality in .
- Maximum-weight independent set: Given a weight function , find an independent set of maximum total weight in .
Algorithm
Unweighted version:
- Initialization: Choose an initial independent set , usually .
- Iteration:
- Build the exchange graph: According to the current independent set , build the exchange graph .
- Path selection: In the exchange graph, from the source to the sink , find an augmenting path .
- Augmentation: Traverse every node along from to :
- If a node belongs to the left part (that is, an element of ), remove that element from .
- If a node belongs to the right part (that is, an element of ), add that element to .
- Repeat: After updating , repeat the steps until no new augmenting path can be found.
- Result: The final independent set is a maximum independent set in the matroid intersection .
Weighted version:
To find an independent set with maximum total weight, optimize the choice of augmenting path.
- Weight assignment: For each element , define its weight in the exchange graph:
- Left-part vertex (an element of ): .
- Right-part vertex (an element of ): .
- Path selection: In the exchange graph , from the source to the sink , find an augmenting path such that augmenting along the path maximizes the increase in the total weight of .
- Augmentation condition: The total weight of elements added along is greater than the total weight of elements removed, namely
- Augmentation: Traverse every node along from to :
- If a node belongs to the left part (that is, an element of ), remove that element from .
- If a node belongs to the right part (that is, an element of ), add that element to .
- Iteration: Repeat steps 1 through 3, repeatedly building the exchange graph and finding augmenting paths to improve the total weight of .
- Termination condition: Terminate when no path satisfying the augmentation condition can be found in the exchange graph.
- Result: The final independent set is a maximum-weight independent set in the matroid intersection .
Complexity:
-
Number of augmentations: If the maximum ranks of the two matroids are and , respectively, the maximum number of augmentations is .
-
Complexity of each augmentation:
- Building the exchange graph takes time, where .
- The complexity of finding an augmenting path depends on the path-search strategy and is usually , for example when using breadth-first search.
-
Total time complexity: The overall time complexity is , where .
Example Problems
Minimum Spanning Tree:
Given an undirected graph in which every edge has weight . Find a spanning tree containing all vertices with minimum total weight.
- For details, see Minimum Spanning Tree.
- Problem template: Luogu P3366 (Template) Minimum Spanning Tree.
Solution Idea
Use Kruskal's algorithm: sort all edges in ascending order of weight, then select edges one by one, adding an edge to the spanning tree if it does not create a cycle. The resulting spanning tree is a minimum spanning tree.
Colorful Graph:
Given an undirected graph with multiple colors , where each edge has a color attribute. Find a largest edge set such that:
- The selected edges contain no cycle.
- The number of edges of each color is at most ( is a given positive integer).
Solution Idea
-
Matroid modeling:
- Graphical matroid (): Defined as all edge sets containing no cycle; the independent-set family contains all edge sets that do not form a cycle.
- Color matroid (): Defined as edge sets containing at most edges of each color; the independent-set family contains all edge sets satisfying the per-color edge bound .
-
Solve the matroid intersection: Solve to find the largest edge set that contains no cycle and uses at most edges of each color.
Constrained Resource Allocation Problem:
A resource allocation problem has a set of resources and a set of projects . Each project requires a certain amount of resources, and the total allocation of each resource cannot exceed its supply.
Goal: Find a resource allocation plan that satisfies all project requirements without exceeding the resource supplies.
Solution Idea
-
Matroid modeling:
- Demand matroid (): Defined as allocation plans satisfying the resource demands of each project; the independent-set family contains all resource-allocation sets satisfying the project requirements.
- Supply matroid (): Defined as allocation plans not exceeding the supply of each resource; the independent-set family contains all resource-allocation sets satisfying the resource-supply constraints.
-
Solve the matroid intersection: Solve to find a resource allocation plan that satisfies all project requirements without exceeding resource supplies.