Kruskal for maximum spanning forest: Difference between revisions
No edit summary |
(chapters added) |
||
Line 1: | Line 1: | ||
[[Category:Videos]] | [[Category:Videos]] | ||
{{#ev:youtube|https://www.youtube.com/watch?v=Pz6x3BB86YA|500|right|Algorithmus von Kruskal|frame}} | {{#ev:youtube|https://www.youtube.com/watch?v=Pz6x3BB86YA|500|right|Chapters | ||
#[00:00] Einführung | |||
#[01:59] Der Algorithmus von Kruskal anhand eines Beispiels | |||
#[06:56] Und wie ist das bei mehreren Zusammenhangskomponenten? | |||
#[07:29] Welches Problem löst der Algorithmus von Kruskal genau? | |||
#[08:05] Wie lautet die Invariante? | |||
#[08:33] Warum ist der Algorithmus korrekt? | |||
#[08:59] Wie wird die Invariante sichergestellt? | |||
#[10:25] Was ist die asymptotische Komplexität des Algorithmus? | |||
|frame}} | |||
'''Algorithmic problem:''' [[Maximum spanning forest]] | '''Algorithmic problem:''' [[Maximum spanning forest]] | ||
Revision as of 14:10, 20 June 2015
Algorithmic problem: Maximum spanning forest
Prerequisites:
Type of algorithm: loop
Auxiliary data:
- A sorted sequence
whose items are the edges of . The edges are sorted in descending order, that is, the edge with the largest value of is the first element of the sequence (ties arbitrarily broken). Below, denotes the -th edge in . - A union-find data structure
on .
Abstract view
Invariant: After
- The undirected graph
, where is the set of all selected edges immediately after the -th iteration, is cycle-free; in particular, it is maximally cycle-free in the sense that, for , adding an edge would close a cycle in . - For the undirected graph
, there is a maximum spanning forest of such that . - The sets of
are the connected components of .
Variant:
Break condition:
Induction basis
Abstract view:
is initialized by , so each node is a singleton in .
Implementation: Obvious.
Proof: Nothing to show.
Induction step
Abstract view: If inserting
Implementation:
- Let
denote the endnodes of , that is, . - If
and belong to different sets in :- Insert
in the result. - Unite the sets of
and in .
- Insert
Correctness: The first and third invariants are obvious. So we focus on the second invariant. We may safely set
- either
and is inserted in the -th iteration - or
and is rejected in the -th iteration.
Note that the case that
As
Complexity
Statement: The asymptotic complexity is in
Proof: The summand