Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut...

9
Minimum Spanning Minimum Spanning Trees Trees Easy Easy

Transcript of Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut...

Page 1: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.

Minimum Spanning Minimum Spanning TreesTrees

EasyEasy

Page 2: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.

TermsTerms

NodeNode EdgeEdge CutCut

CutCut respects a set of respects a set of edgesedges Light EdgeLight Edge Minimum Spanning TreeMinimum Spanning Tree

Page 3: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.

Generic AlgorithmGeneric Algorithm

1.1. Start with an empty set of edges.Start with an empty set of edges.

2.2. Continuously add only edges that are part of Continuously add only edges that are part of a minimum spanning tree a minimum spanning tree

3.3. Stop when we have a minimum spanning Stop when we have a minimum spanning tree.tree.

Page 4: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.

Kruskal’s AlgorithmKruskal’s Algorithm

1.1. Find the smallest edge in the graph.Find the smallest edge in the graph.

2.2. If it connects two unconnected sets, add it.If it connects two unconnected sets, add it.

3.3. Repeat for each edge.Repeat for each edge.

What are the optimal data structures?What are the optimal data structures?

O( E lg V)O( E lg V) E = # edgesE = # edges V = # nodes (vertices)V = # nodes (vertices)

Page 5: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.
Page 6: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.

Prim’s AlgorithmPrim’s Algorithm

1.1. Start with a set of 1 nodes: V and empty set Start with a set of 1 nodes: V and empty set of edges Aof edges A

2.2. Pick a light edge and add it to A.Pick a light edge and add it to A.

3.3. Repeat until all nodes are in V.Repeat until all nodes are in V.

Best Data Structures?Best Data Structures? O(E lg V) or O(E+V lg V)O(E lg V) or O(E+V lg V)

Page 7: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.
Page 8: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.

Other AlgorithmsOther Algorithms

BorBorůůvka's algorithm, O( E lg V )vka's algorithm, O( E lg V )

Bernard Chazelle, O( E α(V)) Bernard Chazelle, O( E α(V))

Randomized, expected Randomized, expected OO((EE) ) Karger, Klein, and Tarjan

Page 9: Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.

Distributed MSTDistributed MSTLAN 1

LAN 2

LAN 3

B1

B2

B3

B4