0% found this document useful (0 votes)
2 views13 pages

Sohom 190301120001 Presentation

The document covers the concepts of trees in graph theory, including their properties, types (such as rooted trees and binary trees), and definitions of key terms like ancestors, descendants, and siblings. It also discusses spanning trees and minimum spanning trees (MST), detailing Kruskal's algorithm for finding the MST. The document provides examples and illustrations to clarify these concepts.

Uploaded by

riksohom3
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)
2 views13 pages

Sohom 190301120001 Presentation

The document covers the concepts of trees in graph theory, including their properties, types (such as rooted trees and binary trees), and definitions of key terms like ancestors, descendants, and siblings. It also discusses spanning trees and minimum spanning trees (MST), detailing Kruskal's algorithm for finding the MST. The document provides examples and illustrations to clarify these concepts.

Uploaded by

riksohom3
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/ 13

Module 7 : Trees & its properties , spanning tree , MST ,

Kruskal’s algorithm

Tree : A tree is a connected graph with no cycle .


1
A

2 6
A
A

3 7
A 5 8 A

4 5 A
9
A
A
A

11
10 11
T
A
A

For example : 1.

G1 (Disconnected Graph) G2
2.
A
B
A

D C
A
A

So to become a tree a graph has to be a connected graph and a non cyclic graph
as well .
Properties :
1. Trees has no cycle .
2. Tree has (n-1) edges , here n is number of vertices .

1 6
A
A

2 7
A

4
A

3 5
A 5 8
A

A
A

10 9
A A

T
Lets take another example .

3. Tree is a connected graph .


4. Every edge is a bridge .

.
A
B
A
A

D
C
A

5. Any two vertices of tree are connected by exactly one path or edge .
Ok now lets take some example to understand the concept more .

It is a tree because .
i) It is a connected graph
ii) It has no cycle .

It is not a tree because it’s


disconnected graph
basically

A B
It’s not a tree because it has a
A A
cycle
C
A

E D A

A
A
Rooted Tree :
Rooted tree is a tree in which some node in distinguished as a root .

A
Root Node A

B C
A

H
A

D E F G A

A
I A

A A
A

A – Root Node
B – Parent node for D &E
C – Parent node for F , G & H
H – Parent node for I

Ancestor : A node higer than parent node . Lets take I node . H is the
parent node of I and C is higher node than H , So C is ancestor of I
node .
Descendant : Just opposite of the Ancestor concept . The lower node
than the child node is descendant . So lets take C node , H is one of
his child nodes and I is lower node than H ( I is child nide of H ) .
Then we can say I is the descendant of C node .
Siblings : If nodes having a common parent node then those nodes
can be called as siblings . Here B & C nodes having a same parent A .
So we can say B & C are siblings .
But if we take E and F , are they siblings ? no they have different
parent nodes . E has B as parent and F has C .
Leaf node : Leaf node are those node who don’t have any child node .
So as per the diagram , D , E , F , G & I don’t have any child node , so
they are leaf nodes .
Interior node : These are those nodes who are neither root node nor
leaf node . As per the diagram , B,C & H are interior nodes , as they
are nor root node nor leaf node .

Level :
There is another important term called level . We always start with
root node as level 0

A
Level 0 Root Node A

B C
Level 1
A

A
Level 1
A

H
Level 2 A

A
Level 2
D E F G A

Level 3
A
I A

A A
A

Height : It is the longest length of the path between root node to any
leaf node
It is determined by the total number of edges we cross during
travelling from root – leaf .
So as per diagram A-I is the longest distance as we have to cross 3
edges (A-C , C-H , H-I)
Binary Trees :
Binary tree is a tree whose each node can contain upto 2 leaves or
atmost 2 child nodes .
So the tree can have 0 , 1 or 2 child nodes .

B C
A

A
G
A

D E F
H
A

A
A
A
A

As per this diagram we can see that A has 2 child nodes , B & C also
have two , G has 1 & D,E,F and H has 0 . So it can satisfy any of
those three conditions it may have 0 child nodes or 1 or 2 .
In this case we can call the diagram a binary tree .
For binary tree the left child node or the right child node can have the
greater , less or equal value compare to its parent node .

Strict / Proper / Full binary tree :


A binary tree can be called as a strict / proper or full binary tree if
each node can have either 0 or 2 child node .

1 2

X
A
Complete Binary tree :
All level except possibly the last levels are filled and all nodes are
as left as possible .

Not CBT NOT

Perfect Binary tree :


All the levels are complete filled .

Balenced binary tree :


We can define it as absolute difference height of left and right subtree
for each node is not more than K (mostly 1)
Diff = | h left – h right |
1
0
A

2 A
3 |1-2| = 1
0
A

0 4 5A 0 6 A
A 0 7
D

0
8
D
A
A A

0
A
A

0 0
A
0
0 A

0 9 A
13
A
10 11 12
3
A
A
A
A A
A 10 A
A

A A

A A
A
Spanning tree :
A spanning tree for a graph G is a subgraph of G which contains all
the vertices of G and is a tree .
For example :
2
2 1
1
A

3
A
A
3 A

5 4
5 4 A

G A G’ A
A
A

Question : Make 3 spanning tree from the below graph .


A

Ans :

1 2 3

X
A
Properties :
1. It must be connected graph
2. It should have n-1 edges where n is number of vertices of the
graph .
3. It will contain all the vertices of the main graph .

If we take a complete graph denoted by Kn then that graph can have


n n-2 spanning trees .

Minimum spanning tree :

10
According to this diagram this is a complete 1 2

Graph with 4 vertices . So it will be denoted


20 50 40
60
n-2
As K4 . Now according to n formula
4 3
this graph can have 44-2 = 4 2 = 16 spanning 30

trees . G
G’ is a subgraph of graph G .
30

10
1 2
It contains all the vertices of G graph .
It’s a connected graph with no cycle . 20

So G’ can be called as spanning tree of 4 3


30
G graph .
G’
Here the total weight count of G’ graph is 30

10+20+30 = 60
It’s the lowest possible total weight
Ok lets take another spanning tree and count its total weight .
10
1 2

60
Here the total weight count is 10+60+20 = 90
20

4 3
-
+

So a minimum spanning tree (MST) is a spanning tree with minimum


possible total weight .

Properties :
i) It has (n-1) edges .
ii) Weight of MST = sum of weight of edges of MST
iii) Maximum path length between two vertices are (n-1)
iv) Only one path from one vertex to another .
v) Removal of edge disconnects the graph .
vi) Graph with distinct weights ~ MST is unique .

Kruskal’s Algorithm :

Step 1 : list all the edges of the graph in order of increasing weight .
Step 2 : select the smallest edge of the graph
Step 3 : select another smallest edge in such a way that it doesn’t
make any circuit .
Step 4 : Continue this process until (n-1) edges have been selected
Q.Find out the min spanning tree using Kruskal’s algorithm .

4.5

6.0

Step 1 :
Edge Weight
(e,f) 2
(f,d) 2.5
(a,f) 3
(f,b) 3
(b,d) 4.5
(b,c) 4.8
(a,b) 5
(a,e) 5.6
(e,d) 6.0
(e,c) 6.1
(d,c) 7.0
(a,c) 10.2
Step 2 : f

Step 3 :
f
i)
2 2.5

e d

ii) a b

3 3

f
2 2.5

e d

iii) a b

3 4.8
3
c
f
2 2.5

e d

Step 4 :
Weight of the tree : 2+2.5+3+3+4.8 = 15.3 , So this is the minimum
possible weight of the tree using Kruskal’s algorithm .
Presented and Created by : Sohom Ghorai
Regd. No : 190301120001
B.Tech CSE
CUTM , BBSR

You might also like