Weighted matroid
In combinatorics, a branch of mathematics, a weighted matroid is a matroid endowed with function with respect to which one can perform a greedy algorithm.
A weight function [math]\displaystyle{ w : E \rightarrow \mathbb{R}^+ }[/math] for a matroid [math]\displaystyle{ M = (E, I) }[/math] assigns a strictly positive weight to each element of [math]\displaystyle{ E }[/math]. We extend the function to subsets of [math]\displaystyle{ E }[/math] by summation; [math]\displaystyle{ w(A) }[/math] is the sum of [math]\displaystyle{ w(x) }[/math] over [math]\displaystyle{ x }[/math] in [math]\displaystyle{ A }[/math]. A matroid with an associated weight function is called a weighted matroid.
Spanning forest algorithms
As a simple example, say we wish to find the maximum spanning forest of a graph. That is, given a graph and a weight for each edge, find a forest containing every vertex and maximizing the total weight of the edges in the tree. This problem arises in some clustering applications. If we look at the definition of the forest matroid above, we see that the maximum spanning forest is simply the independent set with largest total weight — such a set must span the graph, for otherwise we can add edges without creating cycles. But how do we find it?
Finding a basis
There is a simple algorithm for finding a basis:
- Initially let [math]\displaystyle{ A }[/math] be the empty set.
- For each [math]\displaystyle{ x }[/math] in [math]\displaystyle{ E }[/math]
- if [math]\displaystyle{ A \cup \{ x\} }[/math] is independent, then set [math]\displaystyle{ A }[/math] to [math]\displaystyle{ A \cup \{ x\} }[/math].
The result is clearly an independent set. It is a maximal independent set because if [math]\displaystyle{ B \cup \{ x\} }[/math] is not independent for some subset [math]\displaystyle{ B }[/math] of [math]\displaystyle{ A }[/math], then [math]\displaystyle{ A \cup \{ x\} }[/math] is not independent either (the contrapositive follows from the hereditary property). Thus if we pass up an element, we'll never have an opportunity to use it later. We will generalize this algorithm to solve a harder problem.
Extension to optimal
An independent set of largest total weight is called an optimal set. Optimal sets are always bases, because if an edge can be added, it should be; this only increases the total weight. As it turns out, there is a trivial greedy algorithm for computing an optimal set of a weighted matroid. It works as follows:
- Initially let [math]\displaystyle{ A }[/math] be the empty set.
- For each [math]\displaystyle{ x }[/math] in [math]\displaystyle{ E }[/math], taken in (monotonically) decreasing order by weight
- if [math]\displaystyle{ A \cup \{ x \} }[/math] is independent, then set [math]\displaystyle{ A }[/math] to [math]\displaystyle{ A \cup \{ x \} }[/math].
This algorithm finds a basis, since it is a special case of the above algorithm. It always chooses the element of largest weight that it can while preserving independence (thus the term "greedy"). This always produces an optimal set: suppose that it produces [math]\displaystyle{ A=\{e_1,e_2,\ldots,e_r\} }[/math] and that [math]\displaystyle{ B=\{f_1,f_2,\ldots,f_r\} }[/math]. Now for any [math]\displaystyle{ k }[/math] with [math]\displaystyle{ 1\le k\le r }[/math], consider open sets [math]\displaystyle{ O_1=\{e_1,\ldots,e_{k-1}\} }[/math] and [math]\displaystyle{ O_2=\{f_1,\ldots,f_k\} }[/math]. Since [math]\displaystyle{ O_1 }[/math] is smaller than [math]\displaystyle{ O_2 }[/math], there is some element of [math]\displaystyle{ O_2 }[/math] which can be put into [math]\displaystyle{ O_1 }[/math] with the result still being independent. However [math]\displaystyle{ e_k }[/math] is an element of maximal weight that can be added to [math]\displaystyle{ O_1 }[/math] to maintain independence. Thus [math]\displaystyle{ e_k }[/math] is of no smaller weight than some element of [math]\displaystyle{ O_2 }[/math], and hence [math]\displaystyle{ e_k }[/math] is of at least a large a weight as [math]\displaystyle{ f_k }[/math]. As this is true for all [math]\displaystyle{ k }[/math], [math]\displaystyle{ A }[/math] is weightier than [math]\displaystyle{ B }[/math].
Complexity analysis
The easiest way to traverse the members of [math]\displaystyle{ E }[/math] in the desired order is to sort them. This requires [math]\displaystyle{ O(|E|\log|E|) }[/math] time using a comparison sorting algorithm. We also need to test for each [math]\displaystyle{ x }[/math] whether [math]\displaystyle{ A \cup \{ x \} }[/math] is independent; assuming independence tests require [math]\displaystyle{ O(f(|E|)) }[/math] time, the total time for the algorithm is [math]\displaystyle{ O(|E|\log|E| + |E|f(|E|)) }[/math].
If we want to find a minimum spanning tree instead, we simply "invert" the weight function by subtracting it from a large constant. More specifically, let [math]\displaystyle{ w_{\text{min}}(x) = W - w(x) }[/math], where [math]\displaystyle{ W }[/math] exceeds the total weight over all graph edges. Many more optimization problems about all sorts of matroids and weight functions can be solved in this trivial way, although in many cases more efficient algorithms can be found that exploit more specialized properties.
Matroid requirement
Note also that if we take a set [math]\displaystyle{ I }[/math] of "independent" sets which is a down-set but not a matroid, then the greedy algorithm will not always work. For then there are independent sets [math]\displaystyle{ I_1 }[/math] and [math]\displaystyle{ I_2 }[/math] with [math]\displaystyle{ |I_1|\lt |I_2| }[/math], but such that for no [math]\displaystyle{ e\in I_2\setminus I_1 }[/math] is [math]\displaystyle{ I_1\cup e }[/math] independent.
Pick an [math]\displaystyle{ \epsilon\gt 0 }[/math] and [math]\displaystyle{ \tau\gt 0 }[/math] such that [math]\displaystyle{ (1+2\epsilon)|I_1|+\tau|E|\lt |I_2| }[/math]. Weight the elements of [math]\displaystyle{ I_1\cup I_2 }[/math] in the range [math]\displaystyle{ 2 }[/math] to [math]\displaystyle{ 2+2\epsilon }[/math], the elements of [math]\displaystyle{ I_1\setminus I_2 }[/math] in the range [math]\displaystyle{ 1+\epsilon }[/math] to [math]\displaystyle{ 1+2\epsilon }[/math], the elements of [math]\displaystyle{ I_2\setminus I_1 }[/math] in the range [math]\displaystyle{ 1 }[/math] to [math]\displaystyle{ 1+\epsilon }[/math], and the rest in the range [math]\displaystyle{ 0 }[/math] to [math]\displaystyle{ \tau }[/math]. The greedy algorithm will select the elements of [math]\displaystyle{ I_1 }[/math], and then cannot pick any elements of [math]\displaystyle{ I_2\setminus I_1 }[/math]. Therefore, the independent set it constructs will be of weight at most [math]\displaystyle{ (1+2\epsilon)|I_1|+\tau|E|+|I_1\cup I_2| }[/math], which is smaller than the weight of [math]\displaystyle{ I_2 }[/math].
History
It was not until 1971 that Jack Edmonds connected weighted matroids to greedy algorithms in his paper "Matroids and the greedy algorithm". Korte and Lovász would generalize these ideas to objects called greedoids, which allow even larger classes of problems to be solved by greedy algorithms.
References
- Jack Edmonds. Matroids and the Greedy Algorithm. Mathematical Programming, volume 1, p. 125–136. 1971.
Original source: https://en.wikipedia.org/wiki/Weighted matroid.
Read more |