= E V V w T ( ) w e ( ) ( ( ) ) = Def. Def. A A - - PDF document

e v v w t w e def def a a weighted weighted graph graph
SMART_READER_LITE
LIVE PREVIEW

= E V V w T ( ) w e ( ) ( ( ) ) = Def. Def. A A - - PDF document

Minimal Spanning Trees Minimal Spanning Trees Minimal Spanning Trees Minimal Spanning Trees Vertices Vertices Edges Edges Def. Def. A A minimum minimum spanning spanning subtree subtree of a weighted graph of a weighted graph Let


slide-1
SLIDE 1

1

Let be a connected undirected graph with Let be a connected undirected graph with

Minimal Spanning Trees Minimal Spanning Trees

( ) ( )

, G V E =

Vertices Vertices Edges Edges

E V V ⊆ × ⊆ ×

Def.

  • Def. A

A weighted weighted graph graph is a undirected graph is a undirected graph with with weight weight function function

( ) ( )

, G V E =

: w E →

Def.

  • Def. A

A spanning spanning tree tree T T

  • f
  • f G

G is a is a subgraph subgraph of

  • f a

a undirected graph of undirected graph of G G s.t s.t. . 1) 1) T T is a tree, i.e., a connected acyclic graph is a tree, i.e., a connected acyclic graph 2) 2) V(T)=V(G) V(T)=V(G)

Minimal Spanning Trees Minimal Spanning Trees

Def.

  • Def. A

A minimum minimum spanning spanning subtree subtree of a weighted graph

  • f a weighted graph

is a spanning is a spanning subtree subtree of

  • f G

G

  • f minimum weight
  • f minimum weight

( ) ( )

, G w

( ) ( )

e T

w T w e

= ∑

Minimum Spanning Minimum Spanning Subtree Subtree Problem: Problem: Given a Given a weighted connected undirected graph weighted connected undirected graph ( (G,w G,w) ), find a , find a minimum spanning minimum spanning subtree subtree

Example of a Example of a Minimal Spanning Tree Minimal Spanning Tree Minimal Spanning Trees Minimal Spanning Trees We will look at two Algorithms: We will look at two Algorithms:

  • Kruskal

Kruskal

  • Prim ~

Prim ~ Dijkstra Dijkstra’ ’s s Shortest Shortest paths algorithm paths algorithm

Both are Both are $Greedy$ $Greedy$ algorithms algorithms

The Generic Algorithm The Generic Algorithm

This algorithm grows a set of edges This algorithm grows a set of edges A A of

  • f G

G which which upon termination of the algorithm becomes a minimal upon termination of the algorithm becomes a minimal spanning tree of spanning tree of G G. .

  • In

In Kruskal Kruskal’ ’s s algorithm, algorithm, A A is a coalescing is a coalescing forest forest

  • In

In Prim Prim’ ’s s algoritm algoritm, , A A is an expanding tree is an expanding tree Property preserved by Loop: Property preserved by Loop: A A is a subset of is a subset of some minimum spanning tree some minimum spanning tree

Safe Edges Safe Edges

Def.

  • Def. A

A safe safe edge edge for for A A is am edge is am edge ( (u,v u,v) ) not in not in A A s.t s.t. . A satisfies property P also A satisfies property P also satisfies property P satisfies property P

A

{ }

( , ) A u v ∪

Note: Note: If If A A is not a minimum spanning tree, then is not a minimum spanning tree, then there exists a safe edge that can be added to there exists a safe edge that can be added to A A. .

Problem: Problem: How do we find safe edges? How do we find safe edges?

slide-2
SLIDE 2

2

Terminology Terminology

Def. Def. A A cut cut (S,V (S,V-

  • S)

S) of an undirected graph

  • f an undirected graph

G=(V,E) G=(V,E) is a is a partion partion of the vertices V of G into two

  • f the vertices V of G into two

disjoint sets disjoint sets S S and and V V-

  • S

S, i.e., , i.e., s.t s.t. .

  • An edge

An edge crosses crosses the cut the cut (S,V (S,V-

  • S)

S) if one of if one of its endpoints lies in its endpoints lies in S S and the other lies in and the other lies in V V-

  • S

S. . A cut A cut respects respects a set of edges a set of edges A A of

  • f G

G if no edge of if no edge of A A crosses the cut. crosses the cut.

( ) V S V S = − = − ∪ ( ) S V S ∅ = ∅ = − ∩

( , ) u v E ∈

More Terminology More Terminology

Def. Def. An edge crossing a cut An edge crossing a cut (S,V (S,V-

  • S)

S) of a weighted

  • f a weighted

undirected graph undirected graph ( (G,w G,w) ) is a is a light light edge edge if its weight if its weight is minimum of the weight of any edge crossing the is minimum of the weight of any edge crossing the cut. cut. Note: Note: An edge is a An edge is a light light edge edge satisfying satisfying property property P P if its weight is the minimum of any edge satisfying if its weight is the minimum of any edge satisfying property P. property P.

Example of a Cut Example of a Cut Minimal Spanning Trees Minimal Spanning Trees

Theorem.

  • Theorem. Given

Given Let Let

  • G=(V,E)

G=(V,E) connected a connected a undir undir graph graph

  • w:E

w:E R R a weight function on a weight function on G G

  • be

be s.t s.t. . A A lies in some minimum lies in some minimum spanning tree spanning tree

  • (S,V

(S,V-

  • S)

S) be a cut of be a cut of G G that respects that respects A A

  • (

(u,v u,v) ) be a light edge crossing be a light edge crossing (S,V (S,V-

  • S)

S)

A E ⊆

Then Then ( (u,v u,v) ) is safe! is safe!

Proof Proof

A= A= Shaded Edges Shaded Edges

Kruskal Kruskal’ ’s s Algorithm Algorithm

Cor Cor. . Given Given (G=( (G=(V,E),w V,E),w) ) is a connected is a connected undirected weighted graph. undirected weighted graph. Let Let A A be a subset of be a subset of E E lying in a minimum lying in a minimum weight weight subtree subtree of

  • f G

G, and let , and let C C be a be a connected component of a forest connected component of a forest G GA

A=(V,A).

=(V,A). If If ( (u,v u,v) ) is a light edge connecting C to some is a light edge connecting C to some

  • ther component of
  • ther component of G

GA

A, then

, then ( (u,v u,v) ) is safe for is safe for A A

slide-3
SLIDE 3

3

Kruskal Kruskal’ ’s s Algorithm Algorithm Kruskal Kruskal’ ’s s Algorithm Algorithm Kruskal Kruskal’ ’s s Algorithm (Cont.) Algorithm (Cont.) Prim Prim’ ’s s Algorithm Algorithm