Algorithm Theory

Chapter 2 Greedy Algorithms

Part IV: The Greedy Algorithm for

Fabian Kuhn Matroids

• Same as MST, but more abstract… Simple example: 퐸 ≔ 1, 2, 3, 4 system ∅, 1 , 2 , 3 , 4 , 1,2 , 1,3 , : pair 푬, 푰 퐼 ≔ 1,4 , 2,3 , 2,4 , {3,4} • 푬: , called the ground set • 푰: finite family of finite of 퐸 (i.e., 퐼 ⊆ 2퐸), called independent sets (퐸, 퐼) needs to satisfy 3 properties: 1. is independent, i.e., ∅ ∈ 푰 (implies that 퐼 ≠ ∅) 2. Hereditary property: For all 퐴 ⊆ 퐸 and all 퐴′ ⊆ 퐴, if 푨 ∈ 푰, then also 푨′ ∈ 푰 3. Augmentation / Independent set exchange property: If 퐴, 퐵 ∈ 퐼 and 퐴 > |퐵|, there exists 푥 ∈ 퐴 ∖ 퐵 such that 퐁′ ≔ 푩 ∪ 풙 ∈ 푰 Algorithm Theory Fabian Kuhn 2 Example

• Fano matroid: – Smallest finite projective plane of order 2…

Algorithm Theory Fabian Kuhn 3 Matroids and Greedy Algorithms

Weighted matroid: each 푒 ∈ 퐸 has a weight 푤 푒 ≥ 0 • Recall that all independent sets in 퐼 consist of a finite set of elements of 퐸.

Goal: find maximum weight independent set

Greedy algorithm: 1. Start with 푆 = ∅ 2. Add max. weight 푥 ∈ 퐸 ∖ 푆 to 푆 such that 푆 ∪ 푥 ∈ 퐼

Claim: greedy algorithm computes optimal solution

Algorithm Theory Fabian Kuhn 4 Matroid 퐸, 퐼 , Greedy is Optimal weights 푤 푥 ≥ 0 for all 푥 ∈ 퐸 • 푆: greedy solution 퐴: any other solution

Algorithm Theory Fabian Kuhn 5 Matroids: Examples

Forests of a graph 푮 = (푽, 푬): • forest 퐹: subgraph with no cycles (i.e., 퐹 ⊆ 퐸) • ℱ: set of all forests  (퐸, ℱ) is a matroid • Greedy algorithm gives maximum weight forest – equivalent to MST problem

Bicircular matroid of a graph 푮 = 푽, 푬 : • ℬ: set of edges such that every connected has ≤ 1 cycle • (퐸, ℬ) is a matroid  greedy gives max. weight such subgraph

Linearly independent vectors: • Vector space 푉, 퐸: finite set of vectors, 퐼: sets of lin. indep. vect. • Fano matroid can be defined like that

Algorithm Theory Fabian Kuhn 6 Forest Matroid of Graph 퐺 = 푉, 퐸

Ground set: 퐸 (edges) Independent sets: ℱ (forests of 퐺) Basic properties: ∅ ∈ ℱ + hereditary property • Empty graph has no cycles, removing edges doesn’t create cycles Independent set exchange property:

• Given ℱ1, ℱ2 s.t. ℱ1 > ℱ2 – ∃푒 ∈ ℱ1 ∖ ℱ2 s.t. ℱ2 ∪ 푒 is a forest • ℱ1 needs to have an edge 푒 connecting two components of ℱ2 – Because it can only have |ℱ2| edges connecting nodes inside components edge 푒 can be 퓕ퟐ 풆 added to ℱ2

퓕ퟏ

푘 nodes Algorithm Theory Fabian Kuhn ⟹ 푘 − 1 edges 7 Greedoid

• Matroids can be generalized even more

• Relax hereditary property: Replace 퐴′ ⊆ 퐴 ∈ 퐼 ⟹ 퐴′ ∈ 퐼 by ∅ ≠ 퐴 ∈ 퐼 ⟹ ∃푎 ∈ 퐴, s. t. 퐴 ∖ 푎 ∈ 퐼

• Augmentation property holds as before

• Under certain conditions on the weights, greedy is optimal for computing the max. weight 퐴 ∈ 퐼 of a greedoid. – Additional conditions automatically satisfied by hereditary property

• More general than matroids

Algorithm Theory Fabian Kuhn 8