Minimum Spanning Tree - PowerPoint PPT Presentation

About This Presentation
Title:

Minimum Spanning Tree

Description:

Input : weighted graph G=(V,E) Output: A subset of E of minimum weight which forms a tree on V. ... How do we check whether a candidate edge (u,v) closes a cycle? ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 6
Provided by: vdou8
Category:

less

Transcript and Presenter's Notes

Title: Minimum Spanning Tree


1
Minimum Spanning Tree
  • Input weighted graph G(V,E)
  • Output A subset of E of minimum weight which
    forms a tree on V.
  • Applications Network design problems
  • The MST is the cheapest subset of edges that
    keeps the graph connected.

2
Minimum Spanning Tree
  • Main idea behind the MST algorithms we will
    discuss
  • At each step, add an edge to the intermediate
    spanning tree (in other words mark it as
    belonging to the spanning tree) so that
  • it does not form a cycle, and
  • it will result in a minimum spanning tree

3
MST Kruskal's algorithm
  • Find the lightest edge in the graph and mark it.
  • Find the lightest unmarked edge.
  • if it does not close a cycle of marked edges,
    mark it
  • Repeat step 2 until every vertex has been
    covered. The marked edges form the minimum
    spanning tree

4
MST Kruskal's algorithm
  • Implementation details
  • At any time during the algorithm, we have an
    intermediate forest. Whenever we mark an edge we
    are essentially combining two trees in one. In
    the end, we will have a single spanning tree.
  • How do we check whether a candidate edge (u,v)
    closes a cycle?
  • use a disjoint set data structure to maintain the
    vertices.
  • if Find(u)Find(v), then u and v belong to the
    same tree.

5
MST Kruskal's algorithm
  • tree ?
  • for each vertex v
  • MakeSet(v)
  • sort the edges by non-decreasing weight
  • for each edge (u,v) in order of non-decreasing
    weight
  • if Find(u) ! Find(v)
  • tree tree ?(u,v)
  • Union(u,v)
  • return tree

Running time O(E lgE)
Write a Comment
User Comments (0)
About PowerShow.com