0% found this document useful (0 votes)
11 views

GT m3

The document provides an overview of trees in graph theory, detailing their properties, types (rooted and binary), and theorems related to paths, edges, and pendant vertices. It explains the concept of spanning trees, their significance in connected graphs, and includes proofs for various properties of trees. Additionally, it discusses distance, centers, and metrics associated with trees, along with practical examples and applications.

Uploaded by

Shlok Gupta
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)
11 views

GT m3

The document provides an overview of trees in graph theory, detailing their properties, types (rooted and binary), and theorems related to paths, edges, and pendant vertices. It explains the concept of spanning trees, their significance in connected graphs, and includes proofs for various properties of trees. Additionally, it discusses distance, centers, and metrics associated with trees, along with practical examples and applications.

Uploaded by

Shlok Gupta
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/ 84

1

Graph theory: Module-3


Trees – properties, pendant vertex, Distance
and centres in a tree - Rooted and binary trees,
counting trees, spanning trees.
TREES
 A tree is a connected graph without any circuits. 2

Trees with one, two, three, and four vertices


Is this graph a tree? 3
Is this graph a tree? 4
5
 a graph must have at least one vertex, and therefore
so must a tree.

 Some authors allow the null tree, a tree without any


vertices.

 It follows immediately from the definition that a tree


has to be a simple graph, that is, having neither a self-
loop nor parallel edges (because they both form
circuits).
Theorems:
6
Show That There is one and only one path between every
pair of vertices in a tree, T.

Proof: Suppose that there are two paths between vertices


V1 and V3,then the union of these two path will contain a
circuit,so it cannot be a tree.

Hence there is one and only one path between every pair
of vertices in a tree, T.
 Proof: Since tree (T) is a connected graph, there
exist at least one path between every pair of7
vertices in a tree (T). Now, suppose between two
vertices a and b of the tree (T) there exist two
paths. The union of these two paths will contain a
circuit and tree (T) cannot be a tree. Hence the
above statement is proved.
Prove that ,If in a graph G there is one 8
and only one path between every pair
of vertices, G is a tree.
 Proof: There is the existence of a path between every pair
of vertices so we assume that graph G is connected. A
circuit in a graph implies that there is at least one pair of
vertices a and b, such that there are two distinct paths
between a and b. Since G has one and only one path
between every pair of vertices. G cannot have any circuit.
Hence graph G is a tree.
Prove that, A tree with n vertices has
n − 1 edges.
9
Proof: We will prove this by Mathematical Induction
Step1: Result is true for n = 1,2,3 as

Step 2:

Step 3: To prove for n=k+1 ,e=k


[ Lets assume we have a tree T , with vertices k+1( if we take any
tree,we get atleast one vertex with degee one,then remove that
type of vertex from tree), for this new Tree T* , the number of
vertices will be k(i.e n=k) ,then e=k-1] then new tree T,we get
number of vertices n=k+1 and edges e=(k+1)-1 i.e e=k.
Hence the theorem
Prove that, Any connected graph with n 10
vertices and n − 1 edges is a tree
Proof:
Let G be a connected graph with n vertices and (n-1) edges.
To show that G is a tree,we shall show that G has no circuit. We shall
prove it by contradiction.
Let G has a circuit.
Then removing an edge from circuit will not disconnect G.
We remove each edge from all the circuits in G and get a graph G*
such that G* has no circuit and is connected since the removal of
edges from circuit does not vertices
Therefore G* will contain n vertices.

Therefore G* is a tree with n vertices ,hence G*has (n-1) edges . But


then G will have more than (n-1) edges ,which is a contradiction.
Hence G has no circuit and is a tree.
Minimally Connected Graph 11
 A connected graph g is said to be minimally
connected ,if removal of an edge from G is
disconnected.
Remove an edge from connected graph
,then graph becomes disconnected..

Then this will be called Minimal tree.


Trival Tree 12
 A tree with only one vertex is called Trival Tree.

Non Trival Tree


A Tree with two or more vertices is called Non-
Trival Tree.
Prove that A graph is a tree if and only if 13
it is minimally connected
Proof:
Let G be the Tree with n vertices and (n-1) edges .
After removal of one edge of G , then G becomes disconnected
with (n-2) edges.
Hence G is minimally connected graph.

Conversely: Let G is minimally connected graph with n vertices.


Then G is connected graph with out circuit. Because if G has
a circuit then remove edge from G leaves G still connected.

Hence G is a tree.
PENDANT VERTICES IN A TREE 14

 a pendant vertex was defined as a vertex of


degree one.

 a pendant vertex is known as a terminal node or leaf node,


or leaf since it has only 1 degree.

 A program to print all the pendant vertices in the graph


15

Sum of all degrees = 2 * (Sum of Edges)

number of edges = number of vertices – 1


Suppose that a tree T has 2 vertices of degree 2, 4
vertices of degree 3, and 3 vertices of degree 4. find the
number of pendant vertices in T.
16
Sum of all degrees = 2 * (Sum of Edges)
(2 vertices) * (2 degrees) + (4 vertices) * (3 degrees) + (3 vertices) *
(4 degrees) + (k vertices) * (1 degree) = (2 * edges)
2*2 + 4*3 + 3*4 + k*1 = 2*e ——-(1)
remember : number of edges = number of vertices – 1
e=(2+4+3+k)-1
e=9+k-1
e=8+k ——-(2)
putting equation 2 in 1 gives
4 + 12 + 12 + k = 2(8+k)
28 + k = 16 + 2k
-2k + k = 16 – 28
-k = -12 k = 12 so total number of pendant vertices are 12
If a tree T has 4 vertices of degree 2, 1 17
vertex of degree 3 and 2 vertices of
degree 4 and 1 vertex of degree 5. find
the number of pendant vertices in T.
18
Prove that: In any tree (with two or
19
more vertices), there are at least two
pendant vertices
Proof:
Let T be the tree with n vertices and (n-1) edges.
(n-1) edges contributes 2(n-1) degree = (2n-2) degree.
Since no isolated vertices in tree,all vertices must have of
degree 1.
So (2n-2)-n = n-2 are remaining degree
If(n-2) degree distribute on (n-2) vertices ,remaining two
vertices become pendant, otherwise we get more
pendant vertices.

Hence there must be atleast 2 pendant vertex in a tree.


DISTANCE AND CENTERS IN A TREE 20
 The tree in Fig. has four vertices. Intuitively, it seems that vertex b
is located more “centrally” than any of the other three vertices.

Inherent in the concept of a center is the idea of “distance,” so we must


define distance before we can talk of a center.

The center of a tree is the node or nodes that minimize the maximum
distance to any other node in the tree. In other words, it is the node or
nodes that are closest to the middle of the tree.
Distance in a Tree: 21
 In a tree, the distance between two nodes is the number of
edges on the path connecting them.
 For example, in the tree shown below, the distance between
nodes A and E is 2, while the distance between nodes B and C
is 1.
22
23

A function that satisfies these three conditions is called a


metric.
24

Identify the distance from one vertex to all other vertices


and then find the maximum distance
Prove that The distance between vertices of a 25
connected graph is a metric.
Theorem: Every tree has either one 26
or two centers
27

Radius and Diameter:


 If a tree has a center (or two centers), does it have a
radius also?
 Yes. The eccentricity of a center (which is the
distance from the center of the tree to the farthest
vertex) in a tree is defined as the radius of the tree.
(Minimum Eccentricity)

 The diameter of a tree T, on the other hand, is


defined as the length of the longest path in
T.(Maximum Eccentricity)
28
Every tree has either one 29

or two centers.
Identify eccentricity,Diameter,radius
30
of the following trees
31

c and d are the center of the tree because of low


eccentricity
NOTE: 32

If we delete all pendant verices of degree 1,center of tree will not


change
2) 33
3) 34

If we delete all pendant verices of degree 1,center of tree will not


change
35
Draw all trees of n labeled 36

vertices for n = 1, 2, 3, 4,
and 5.
Draw all trees of n 37

unlabeled vertices for n =


1, 2, 3, 4, and 5.
38
ROOTED AND BINARY TREES 39

 A tree in which one vertex (called the root) is distinguished


from all the others is called a rooted tree.
 A rooted tree is a tree in which special node or vertex is
single out ,this node is called rooted vertex.
 In a diagram of a rooted tree, the root is generally marked
distinctly. We will show the root enclosed in a small triangle.
Draw all unlabeled rooted trees 40
of n vertices for n = 1, 2, 3, 4,
and 5.
41
Binary Trees: 42
 A binary tree is defined as a tree in which there is exactly one
vertex of degree two, and each of the remaining vertices is of
degree one or three
43
 Sincethe vertex of degree two is distinct from all other vertices,
this vertex serves as a root. Thus every binary tree is a rooted
tree.

 Two properties of binary trees follow directly from the definition:


1) The number of vertices n in a binary tree is always odd.
Proof: Since in a binary tree,there is exactly one vertex of degree
2 and remaining vertices(n-1)are of add degree . Also we know
that the number of vertices of odd degree is even.
44
2) Prove that the number of pendant vertices in a binary tree is
n+1/2
 example of a tree structure that you probably use every
day is a file system. In a file system, directories, or folders, are
structured as a tree 45
 example of a tree is a web page. The following is an
example of a simple web page written using HTML. 46
47
Cite three different situations (games, 48
activities, or problems) that can be
represented by trees. Explain.
SPANNING TREES 49
 A tree T is said to be a spanning tree of a connected graph
G if T is a subgraph of G and T contains all vertices of G.

 the vertices of G are barely hanging together in a spanning


tree, it is a sort of skeleton of the original graph G. This is why
a spanning tree is sometimes referred to as a skeleton or
scaffolding of G.

 Since spanning trees are the largest (with maximum number


of edges) trees among all trees in G, it is also quite
appropriate to call a spanning tree a maximal tree
subgraph or maximal tree of G.
50
 It is to be noted that a spanning tree is defined only for
a connected graph, because a tree is always
connected, and in a disconnected graph of n vertices
we cannot find a connected subgraph with n vertices.
 Each component (which by definition is connected) of
a disconnected graph, however, does have a spanning
tree. Thus a disconnected graph with k components has
a spanning forest consisting of k spanning trees.

 (A collection of trees is called a forest.)


51
 Finding a spanning tree of a connected graph G is
simple. If G has no circuit, it is its own spanning tree.

 If G has a circuit, delete an edge from the circuit.


This will still leave the graph connected .

 If there are more circuits, repeat the operation till


an edge from the last circuit is deleted—leaving a
connected, circuit-free graph that contains all the
vertices of G.
THEOREM : 52
Every connected graph has at least one
spanning tree.

 An edge in a spanning tree T is called a branch of T.

 An edge of G that is not in a given spanning tree T is called


a chord.

For instance, edges b1, b2, b3, b4, b5, and


b6 are branches of the spanning tree, while
edges c1, c2, c3, c4, c5, c6, c7, and c8 are
chords.

It must be kept in mind that branches and


chords are defined only with respect to a
given spanning tree.
 An edge that is a branch of one spanning tree T1
53
(in a graph G) may be a chord with respect to
another spanning tree T2.
 It is sometimes convenient to consider a
connected graph G as a union of two subgraphs,
T and T~; that is,

where T is a spanning tree, and T~ is the complement


of Tin G. Since the subgraph T~ is the collection of
chords, it is quite appropriately referred to as the chord
set (or tie set or cotree) of T.
With respect to any of its spanning trees, a 54
connected graph of n vertices and e
edges has n − 1 tree branches and e − n + 1
chords.
 the graph in previous figure (with n = 7, e = 14), has six
tree branches and eight chords with respect to the
spanning tree { b1, b2, b3, b4, b5, b6} . Any other
spanning tree will yield the same numbers.

 If we have an electric network with e elements (edges)


and n nodes (vertices), what is the minimum number of
elements we must remove to eliminate all circuits in the
network? The answer is
e − n + 1.
If we have a farm consisting of six walled
55
plots of land, as shown in Fig., and these
plots are full of water, how many walls will
have to be broken so that all the water can
be drained out?
56

Here n = 10 and e = 15. We shall have to select


a set of six (15 − 10 + 1 =6) walls
such that the remaining nine constitute a spanning
tree. Breaking these six walls will drain the water out.
Rank and Nullity: 57
 When someone specifies a graph G, the first thing he is
most likely to mention is n, the number of vertices in G. Immediately
following comes e, the number of edges in G. Then k, the number of
components G has.

 If k = 1, G is connected
 How are these three numbers of a graph related?
 Since every component of a graph must have at least one vertex, n
≥ k. Moreover, the number of edges in a component can be no less
than the number of vertices in that component minus one. Therefore,
e ≥ n − k.
 Apart from the constraints n − k ≥ 0 and e − n + k ≥ 0, these three
numbers n, e, and k are independent, and they are fundamental
numbers in graphs.
From these three numbers are derived two other
important numbers called rank and nullity, defined as
58
 rank r = n − k,
 nullity μ = e − n + k.

The rank of a connected graph is n − 1, and


the nullity, e − n + 1.
 rank of G = number of branches in any spanning tree (or
forest) of G,
 nullity of G = number of chords in G,
 rank + nullity = number of edges in G.
 The nullity of a graph is also referred to as its cyclomatic
number, or first Betti number.
FINDING ALL SPANNING TREES OF
59
A GRAPH
 Usually, in a given connected graph there are a large number of
spanning trees.
60

The distance between two spanning trees Ti and Tj of a graph G is defined


as the number of edges of G present in one tree but not in the other. This
distance may be written as d(Ti, Tj).
Tree Graph: 61

 The tree graph of a given graph G is defined as a


graph in which each vertex corresponds to a
spanning tree of G, and each edge corresponds to a
cyclic interchange between the spanning trees of G
represented by the two end vertices of the edge.
SPANNING TREES IN A 62

WEIGHTED GRAPH
 a spanning tree in a graph G is a minimal subgraph
connecting all the vertices of G.
 If graph G is a weighted graph (i.e., if there is a real
number associated with each edge of G), then the
weight of a spanning tree T of G is defined as the sum
of the weights of all the branches in T.
 In general, different spanning trees of G will have
different weights.
 Among all the spanning trees of G, one with the
smallest weight is of practical significance.
63
 A spanning tree with the smallest weight in a
weighted graph is called a shortest spanning tree
or shortest-distance spanning tree or minimal
spanning tree.

 Algorithm for Shortest Spanning Tree:


There are several methods available for actually finding a
shortest spanning tree in a given graph, both by hand and by
computer.
 One algorithm due to Kruskal is as follows:
64
List all edges of the graph G in order of nondecreasing weight.

Next, select a smallest edge of G.

Then for each successive step select (from all remaining edges of
G) another smallest edge that makes no circuit with the previously
selected edges.

Continue
until n − 1 edges have been selected, and these edges will
constitute the desired shortest spanning tree.
Another algorithm, which does not require listing all65
edges in order of nondecreasing weight or checking at
each step if a newly selected edge forms a circuit, is
due to Prim .

For Prim′s algorithm, draw n isolated vertices and label


them v1, v2, . . . , vn.
Tabulate the given weights of the edges of G in an n by
n table. (Note that the entries in the table are symmetric
with respect to the diagonal, and the diagonal is
empty.)
Set the weights of nonexistent edges (corresponding to
those pairs of cities between which no direct road can
be built) as very large.
Find the weight of the minimum spanning tree 66
using Prims Method
67
68

The weight of this tree is 41.5 units.

The weight of its edges is tabulated in Fig

The weight of this tree is 41.5 units.


69
2) 70
3) 71
KRUSKAL’s Algorithm 72

 List all edges of the graph G in order of


nondecreasing weight. Next, select a
smallest edge of G.
 Then for each successive step select (from
all remaining edges of G) another smallest
edge that makes no circuit with the
previously selected edges.
 Continue until n − 1 edges have been
selected, and these edges will constitute
the desired shortest spanning tree.
73
Edge Cost in non
decreasing order)
(1,6) = 10
(3,4)=12
(2,7)=14
(2,3)=16
(4,7)=18
(4,5)=22
(5,7)=24
(5,6)=25
(1,2)=28
74
Edge Cost in
non
decreasing
order)
(1,6) = 10
(3,4)=12
(2,7)=14
(2,3)=16
(4,7)=18
(4,5)=22
(5,7)=24
(5,6)=25
(1,2)=28
75
Edge Cost
in non
decreasin
g order)
(1,6) = 10
(3,4)=12
(2,7)=14
(2,3)=16
(4,7)=18
(4,5)=22
(5,7)=24
(5,6)=25
(1,2)=28
76
Use the algorithm of Kruskal, to find a shortest
spanning tree in the graph of the following figure. 77
THEOREM
A spanning tree T (of a given weighted connected graph G) is a
shortest spanning tree (of G) if and only if there exists no other
spanning tree (of G) at a distance of one from T whose weight is
78
smaller than that of T.
Proof:
 Let T1 be a spanning tree in G satisfying the hypothesis of the
theorem The proof will be completed by showing that if T2 is a
shortest spanning tree (different from T1) in G, the weight of T1 will
also be equal to that of T2. Let T2 be a shortest spanning tree in G.
Clearly, T2 must also satisfy the hypothesis of the theorem
(otherwise there will be a spanning tree shorter than T2 at a
distance of one from T2, violating the assumption that T2 is shortest).
Consider an edge e in T2 which is not in T1. Adding e to T1 forms a
79
fundamental circuit with branches in T1. Some, but not all, of the
branches in T1 that form the fundamental circuit with e may also be
in T2; each of these branches in T1 has a weight smaller than or
equal to that of e, because of the assumption on T1.
Amongst all those edges in this circuit which are not in T2 at least
one, say bj, must form some fundamental circuit (with respect to T2)
containing e. Because of the minimality assumption on T2 weight of
bj cannot be less than that of e.
Therefore bj must have the same weight as e. Hence the spanning
tree = (T1 ⋃e − bj), obtained from T1 through one cycle exchange,
has the same weight as T1. But T1 has one edge more in common
with T2, and it satisfies the condition of Theorem 3-16. This argument
can be repeated, producing a series of trees of equal weight, T1 , T1
, T1, . . . , each a unit distance closer to T2, until we get T2 itself.
This proves that if none of the spanning trees at a unit distance from T
is shorter than T, no spanning tree shorter than T exists in the graph.
Degree-constrained Shortest
spanning tree 80

 The degree-constrained minimum spanning tree (DCMST) is a


special case of MST, which is also an important problem in
network design.

 It consists of finding a spanning tree whose nodes do not exceed


a given maximum degree and whose total edge length is
minimum.
FUNDAMENTAL CIRCUITS 81
 In graph theory, a fundamental circuit is a cycle in a graph that
does not contain any other cycle as a subset.
 A circuit formed by adding a chord to spanning tree T is called
a Fundamental Circuit.

To determine the fundamental circuits in a graph, we


can use the following steps:
 Select a spanning tree (a tree that spans all the
vertices in the graph).
 For each edge that is not in the tree [ i.e. chord set ],
add it to the tree to form a fundamental circuit.
 For all the chords we get a fundamental circuit
82
 if we add an edge between any two vertices of83
a
tree a circuit is created.

THEOREM :A connected graph G is a tree if and only


if adding an edge between any two vertices in G
creates exactly one circuit.

Proof:
Let us now consider a spanning tree T in a
connected graph G. Adding any one chord to T will
create exactly one circuit.
Such a circuit, formed by adding a chord to a
spanning tree, is called a fundamental circuit.
84

You might also like