For a matroid M on ground set E, a weight function on M is a function $w : E -> \mathbb{R}$, extended to all subsets of E by setting $w(X) := \sum_{x\in X} w(x)$. The greedy algorithm for finding a maximum-weight independent subset of E starts with the empty set, and proceeds by successively adding elements of E of maximum weight, which together with the elements already added, form an independent set.
In this method, a weight function is specified by its list of values on E. Thus if $E = \{e_1, ..., e_n\}$, then w is represented as the list $\{w(e_1), ..., w(e_n)\}$.
Matroids can be characterized via the greedy algorithm as follows: a set $\mathcal{I}$ of subsets of E is the set of independent sets of a matroid on E iff $\mathcal{I}$ is nonempty, downward closed, and for every weight function $w : E -> \mathbb{R}$, the greedy algorithm returns a maximal member of $\mathcal{I}$ of maximum weight.
|
|
|
|
|
|
The object maxWeightBasis is a method function.