Maintain a partition of the vertices into clusters

Info iconThis preview shows pages 5–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Maintain a partition of the  vertices into clusters Initially, single-vertex  clusters Keep an MST for each  cluster Merge “closest” clusters  and their MSTs A priority queue stores the  edges outside clusters Key: weight Element: edge At the end of the algorithm One cluster and one MST Minimum Spanning Trees 5 Algorithm KruskalMST ( G ) for each vertex v in G do Create a cluster consisting of v let Q be a priority queue. Insert all edges into Q T { T is the union of the MSTs of the clusters} while T has fewer than n - 1 edges do e Q.removeMin () .getValue () [ u , v ] G.endVertices ( e ) A getCluster ( u ) B getCluster ( v ) if A B then Add edge e to T mergeClusters ( A, B ) return T
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
© 2010 Goodrich, Tamassia Campus Tour 6 Example B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9 B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9 B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9 B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9
Background image of page 6
© 2010 Goodrich, Tamassia Campus Tour 7 Example (contd.) four steps t w o   s e p B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9 B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9 B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9 B G C A F D 4 1 3 5 10 2 8 7 6 E H 11 9
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
© 2010 Goodrich, Tamassia Data Structure for Kruskal’s  Algorithm The algorithm maintains a forest of trees A priority queue extracts the edges by increasing  weight An edge is accepted it if connects distinct trees We need a data structure that maintains a  partition , i.e., a collection of disjoint sets, with  operations: makeSet (u): create a set consisting of u find (u): return the set storing u union (A, B): replace sets A and B with their union Minimum Spanning Trees 8
Background image of page 8
© 2010 Goodrich, Tamassia Minimum Spanning Trees 9 Recall of List-based  Partition Each set is stored in a sequence Each element has a reference back to the set operation  find (u) takes O(1) time, and returns the set of  which u is a member. in operation 
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page5 / 17

Maintain a partition of the vertices into clusters...

This preview shows document pages 5 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online