Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 21

Minimum

Spanning Trees
Presented by :
M.Adnan & Alamgir

MST

A minimum spanning tree connects all nodes


in a given graph

A MST must be a connected and undirected


graph

A MST can have weighted edges

Multiple MSTs can exist within a given


undirected graph

More about Multiple MSTs

Multiple MSTs can be generated depending on


which algorithm is used

If you wish to have an MST start at a specific


node

However, if there are weighted edges and all


weighted edges are unique, only one MST will
exist

Real Life Application of a MST


A cable TV company is laying cable in a
new neighborhood. If it is constrained to
bury the cable only along certain paths,
then there would be a graph representing
which points are connected by those
paths. Some of those paths might be more
expensive, because they are longer, or
require the cable to be buried deeper;
these paths would be represented by
edges with larger weights. A minimum
spanning tree would be the network with
the lowest total cost.

Borvkas Algorithm

The first MST Algorithm was created by


Otakar Borvka in 1926

The algorithm was used to create efficient


connections between the electricity network
in the Czech Republic

No longer used since Prims and Kruskals


algorithms were discovered

Kruskals Algorithm
Work with edges, rather than nodes
Two steps:

Sort edges by increasing edge weight


Select the first |V| 1 edges that do not
generate a cycle

Walk-Through
F

10

C
3
6

4
1

2
3

Consider an undirected, weight graph

10

C
3
6

4
1

2
3

Sort the edges by increasing edge weight

edge

dv

edge

dv

(D,E)

(B,E)

(D,G)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

(E,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Accepting edge (E,G) would create a cycle

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle

10

3
6

4
1

2
3

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Select first |V|1 edges which do not


generate a cycle
3

F
A

C
3

2
3

D
1

edge

dv

(B,E)

(B,F)

(E,G)

(B,H)

(C,D)

(A,H)

(G,H)

(D,F)

(C,F)

(A,B)

(B,C)

(A,F)

10

edge

dv

(D,E)

(D,G)

Done
Total Cost =

dv = 21

not
considered

THE END

You might also like