{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Method incidentedges is called once for each vertex

Info iconThis preview shows pages 15–17. Sign up to view the full content.

View Full Document Right Arrow Icon
Method incidentEdges is called once for each vertex Label operations We set/get the distance, parent and locator labels of vertex  z   O (deg( z ))   times Setting/getting a label takes  O (1)  time Priority queue operations Each vertex is inserted once into and removed once from the priority  queue, where each insertion or removal takes  O (log n ) time The key of a vertex  w  in the priority queue is modified at most  deg( w ) times, where each key change takes  O (log n ) time  Prim-Jarnik’s algorithm runs in  O (( n + m ) log n )  time provided the  graph is represented by the adjacency list structure Recall that  Σ v deg( v ) = 2 m The running time is  O ( m log n )  since the graph is connected
Background image of page 15

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

View Full Document Right Arrow Icon
©  2010 Goodrich, Tamassia Minimum Spanning Trees 16 Baruvka’s Algorithm (Exercise) Like Kruskal’s Algorithm, Baruvka’s algorithm grows many  clusters at once and maintains a forest  T Each iteration of the while loop halves the number of connected  components in forest  T The running time is  O ( m log n ) Algorithm BaruvkaMST ( G ) T V {just the vertices of G } while T has fewer than n - 1 edges do for each connected component C in T do Let edge e be the smallest-weight edge from C to another component in T if e is not already in T then Add edge e to T return T
Background image of page 16
©  2010 Goodrich, Tamassia Example of Baruvka’s  Algorithm (animated) CSC 316 17 1 5 4 3 2 3 4 4 9 6 8 7 6 5 4 9 6 8 Slide by Matt Stallmann  included with permission. Slide by Matt Stallmann  included with permission. 1 5 4 3 2 3 4 4 9 6 8 7 6 5
Background image of page 17
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}