Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Kruskal's algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Proof of correctness == The proof consists of two parts. First, it is proved that the algorithm produces a [[spanning tree]]. Second, it is proved that the constructed spanning tree is of minimal weight. ===Spanning tree=== Let <math>G</math> be a connected, weighted graph and let <math>Y</math> be the subgraph of <math>G</math> produced by the algorithm. <math>Y</math> cannot have a cycle, as by definition an edge is not added if it results in a cycle. <math>Y</math> cannot be disconnected, since the first encountered edge that joins two components of <math>Y</math> would have been added by the algorithm. Thus, <math>Y</math> is a spanning tree of <math>G</math>. ===Minimality=== We show that the following proposition '''''P''''' is true by [[Mathematical induction|induction]]: If ''F'' is the set of edges chosen at any stage of the algorithm, then there is some minimum spanning tree that contains ''F'' and none of the edges rejected by the algorithm. * Clearly '''''P''''' is true at the beginning, when ''F'' is empty: any minimum spanning tree will do, and there exists one because a weighted connected graph always has a minimum spanning tree. * Now assume '''''P''''' is true for some non-final edge set ''F'' and let ''T'' be a minimum spanning tree that contains ''F''. ** If the next chosen edge ''e'' is also in ''T'', then '''''P''''' is true for ''F'' + ''e''. **Otherwise, if ''e'' is not in ''T'' then ''T'' + ''e'' has a cycle ''C''. The cycle ''C'' contains edges which do not belong to ''F'' + ''e'', since ''e'' does not form a cycle when added to ''F'' but does in ''T''. Let ''f'' be an edge which is in ''C'' but not in ''F'' + ''e''. Note that ''f'' also belongs to ''T'', since ''f'' belongs to ''T'' + ''e'' but not ''F'' + ''e''. By '''''P''''', ''f'' has not been considered by the algorithm. ''f'' must therefore have a weight at least as large as ''e''. Then ''T'' − ''f'' + ''e'' is a tree, and it has the same or less weight as ''T''. However since ''T'' is a minimum spanning tree then ''T'' − ''f'' + ''e'' has the same weight as ''T'', otherwise we get a contradiction and ''T'' would not be a minimum spanning tree. So ''T'' − ''f'' + ''e'' is a minimum spanning tree containing ''F'' + ''e'' and again '''''P''''' holds. * Therefore, by the principle of induction, '''''P''''' holds when ''F'' has become a spanning tree, which is only possible if ''F'' is a minimum spanning tree itself.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)