Minimum Spanning Tree - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Minimum Spanning Tree

Description:

Let G = (V, E) be a connected, undirected graph with a real-valued weight ... If (u, v) is a light edge connecting C to some other component in GA, then (u, v) ... – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 26
Provided by: juliah3
Category:

less

Transcript and Presenter's Notes

Title: Minimum Spanning Tree


1
Minimum Spanning Tree
  • Assume a connected, undirected graph G (V, E).
  • Weight w(u,v) on each edge (u,v) ? E

2
Minimum Spanning Tree
  • A spanning tree whose weight is minimum over all
    spanning trees is called a minimum spanning tree,
    or MST.

3
Growing a Minimum Spanning Tree
  • Assume a connected, undirected graph G (V, E).
  • Assume a weight function w E ? R.
  • Consider greedy generic algorithm that grows
    minimum spanning tree one edge at a time.

4
Generic Algorithm
  • GENERIC-MST(G, w)
  • A ? ?
  • while A does not form a spanning tree
  • do find an edge (u, v) that is safe for A
  • A ? A ? (u, v)
  • return A

5
Terminology
  • A cut (S, V-S) of an undirected graph G (V, E)
    is a partition of V.
  • Let C Si be a collection of nonempty sets. C
    forms a partition of a set S if
  • the sets are pairwise disjoint, and
  • their union is S.
  • I.e., each element of S appears in exactly one Si
    (where Si ? C).

6
Terminology (continued)
  • Edge (u, v) ? E crosses the cut (S, V-S) if one
    of its endpoints is in S and the other is in V-S.
  • A cut respects a set A of edges if no edge in A
    crosses the cut.
  • An edge is a light edge crossing a cut if its
    weight is the minimum of any edge crossing the
    cut.
  • More generally, an edge is a light edge
    satisfying a given property if its weight is the
    minimum of any edge satisfying the property.

7
Safe Edges Theorem
  • Let G (V, E) be a connected, undirected graph
    with a real-valued weight function w defined on
    E. Let A be a subset of E that is included in
    some minimum spanning tree for G, let (S, V-S) be
    any cut of G that respects A, and let (u, v) be a
    light edge crossing (S, V-S). Then edge (u, v) is
    safe for A.

8
Proof of Safe Edges Theorem
9
Corollary to Safe Edges Theorem
  • Let G (V, E) be a connected, undirected graph
    with a real-valued weight function w defined on
    E. Let A be a subset of E that is included in
    some minimum spanning tree for G, and let C
    (VC, EC) be a connected component (tree) in the
    forest GA (V, A). If (u, v) is a light edge
    connecting C to some other component in GA, then
    (u, v) is safe for A.

10
Kruskals Algorithm
  • Let C1 and C2 be two trees.
  • Let edge (u, v) be the edge of least weight that
    connects the two trees.
  • Since (u, v) is a light edge connecting C1 to
    some other tree, it is a safe edge for C.

11
Kruskals Algorithm
  • A ? Ø
  • for each vertex v ?VG
  • do MAKE-SET(v)
  • sort E into nondecreasing order by weight
  • for each (u, v) ?E, taken in nondecreasing order
  • do if FIND-SET(u) ? FIND-SET(v)
  • then A ? A ? (u, v)
  • UNION(u, v)
  • return A

12
Example of Kruskals Algorithm
13
Example (continued)
14
Example (continued)
15
Example (continued)
16
Example (continued)
17
Example (continued)
18
Example (continued)
19
Prims Algorithm
  • Let G be a connected graph.
  • Let r be vertex that will serve as root of
    minimum cost spanning tree.
  • At each step, add to the tree A a light edge that
    connects A to an isolated vertex of GA (V, A).
  • By corollary, this adds only safe edges to A.
  • Choose edge that adds minimum amount possible to
    trees weight.

20
Prims Algorithm
  • MST-PRIM (G, w, r)
  • for each u ?VG
  • do keyu ? 8
  • pu ? NIL
  • keyr ? 0
  • Q ? VG
  • while Q ? ?
  • do u ? EXTRACT-MIN(Q)
  • for each v ?Adju
  • do if v ?Q and w(u, v) lt keyv
  • then pv ? u
  • keyv ? w(u, v)

21
Example of Prims Algorithm
22
Example (continued)
23
Example (continued)
24
Example (continued)
25
Example (continued)
Write a Comment
User Comments (0)
About PowerShow.com