Jump to content

Kruskal's algorithm

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 62.163.16.73 (talk) at 16:19, 27 May 2002 (short description). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Kruskal's algoritm computes the shortest spanning tree in a graph.

It works as follows:

  1. sort the edges by length in ascending order
  2. take the first edge of this list and add it to the tree
  3. if you have reached the end of the list, stop
  4. consider the next edge on the list: if it will form a cycle when added to the tree, discard it; otherwise add it to the tree
  5. go back to step 3