0% found this document useful (0 votes)
16 views23 pages

Nptel Week4 Module5 Spanning Trees

The document discusses the concept of minimum cost spanning trees within the context of restoring a road network after a cyclone. It explains the properties of trees, including their acyclic nature and the unique paths between nodes, and introduces two algorithms for constructing minimum cost spanning trees: Prim's and Kruskal's algorithms. The document emphasizes the importance of selecting roads with the least restoration cost to ensure connectivity across the district.

Uploaded by

litlit6677
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views23 pages

Nptel Week4 Module5 Spanning Trees

The document discusses the concept of minimum cost spanning trees within the context of restoring a road network after a cyclone. It explains the properties of trees, including their acyclic nature and the unique paths between nodes, and introduces two algorithms for constructing minimum cost spanning trees: Prim's and Kruskal's algorithms. The document emphasizes the importance of selecting roads with the least restoration cost to ensure connectivity across the district.

Uploaded by

litlit6677
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

NPTEL MOOC,JAN-FEB 2015

Week 4, Module 5

DESIGN AND ANALYSIS


OF ALGORITHMS
Minimum cost spanning trees

MADHAVAN MUKUND, CHENNAI MATHEMATICAL INSTITUTE


http://www.cmi.ac.in/~madhavan
Example: Road network

District hit by a cyclone, damaging the roads

Government sets to work to restore the roads

Priority is to ensure that all parts of the district can


be reached

What set of roads should be restored first?


Spanning tree
Minimum connectivity:
no loops
3 4
Removing an edge
from a loop cannot
1 2 5 disconnect graph

Connected acyclic
graph — tree

Spanning tree
Spanning tree
Minimum connectivity:
no loops
3 4
Removing an edge
from a loop cannot
1 2 5 disconnect graph

Connected acyclic
graph — tree

Spanning tree
Spanning tree
Minimum connectivity:
no loops
3 4
Removing an edge
from a loop cannot
1 2 5 disconnect graph

Connected acyclic
graph — tree

Spanning tree
Spanning tree with costs
Restoration of each
road has a cost
70 Among the different
3 4
18 6 8 spanning trees,
choose the one with
1 2 5 minimum cost
10 20
Minimum cost
spanning tree
Spanning tree with costs
Restoration of each
Cost = 114 road has a cost
70 Among the different
3 4
18 6 8 spanning trees,
choose the one with
1 2 5 minimum cost
10 20
Minimum cost
spanning tree
Spanning tree with costs
Restoration of each
Cost = 114 Cost = 44 road has a cost
70 Among the different
3 4
18 6 8 spanning trees,
choose the one with
1 2 5 minimum cost
10 20
Minimum cost
spanning tree
Facts about trees
Definition: A tree is a connected acyclic graph

Fact 1: A tree on n vertices has exactly n-1 edges

Start with a tree and delete edges

Initially one single component

Deleting an edge must split a component into two

After n-1 edge deletions, n components, each an


isolated vertex
Facts about trees

Fact 2: Adding an edge to a tree must create a cycle

Suppose we add an edge (i,j)

Tree is connected, so there is already a path p


from i to j

New edge (i,j) plus path p creates a cycle


Facts about trees

Fact 3: In a tree, every pair


of nodes is connected by a
unique path i j

If there are two paths


from i to j, there must be
a cycle
Facts about trees

Any two of the following facts about a graph G


implies the third

G is connected

G is acyclic

G has n-1 edges


Building a minimum cost
spanning trees
Two natural strategies

Start with smallest edge and grow it into a tree

Prim’s Algorithm

Scan edges in ascending order of cost and


connect components to form a tree

Kruskal’s Algorithm
Prim’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Prim’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Prim’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Prim’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Prim’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Kruskal’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Kruskal’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Kruskal’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Kruskal’s algorithm

70
3 4
18 6 8
1 2 5
10 20
Kruskal’s algorithm

70
3 4
18 6 8
1 2 5
10 20

You might also like