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

Trees-graph Theory_module 7

Uploaded by

Manasi Sahukar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Trees-graph Theory_module 7

Uploaded by

Manasi Sahukar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Tree: Introduction

module 7
Dr. Manasi K Sahukar
Introduction
• Tree: A tree is a connected undirected graph with no simple circuits.

• Which of the graphs shown in Figure 2 are trees?


• Solution: G1 and G2 are trees, because both are connected graphs
with no simple circuits.G3 is not a tree because e,b,a,d,e is a simple
circuit in this graph. Finally,G4 is not a tree because it is not
connected.
Bernoulli Family tree
• The graph given below shows the family tree
of the Bernoullis of Switzerland, the most
distinguished family of mathematicians.
• Any connected graph that contains no simple circuits is a
tree.
• What about graphs containing no simple circuits that are
not necessarily connected? These graphs are called
forests and have the property that each of their
connected components is a tree.
• The set of disjoint trees is called a forest.

• Theorem: An undirected graph is a tree if and only if


there is a unique path between any two of its vertices.
Examples
• The graph in Figure 9.2 is connected and contains a unique,
simple path between any two vertices. Therefore, by
Theorem, it is a tree. The same holds for Figure 9.3.
Edge requirement for a connected
graph to be tree
• Theorem : A connected graph with n
vertices is a tree if and only if it has
exactly n - 1 edges.
Rooted tree
• Rooted Tree: The root node of a tree is the node with no parents.
There is at most one root node in a rooted tree. A rooted tree is a
tree in which one vertex has been designated as the root and
every edge is directed away from the root.

Terminology of rooted tree
The terminology for trees has botanical and genealogical origins. Suppose that T is
a rooted tree.
• Leaf: A leaf is a vertex of degree 1 (Pendant vertex). A leaf node has no children
nodes.

• If v is a vertex in T other than the root, the parent of v is the unique vertex u such
that there is a directed edge from u to v(the reader should show that such a vertex
is unique).
• When u is the parent of v, v is called a child of u. Vertices with the same parent are
called siblings.
• The ancestors of a vertex other than the root are the vertices in the path from the
root to this vertex, excluding the vertex itself and including the root (that is, its
parent, its parent’s parent, and so on, until the root is reached).
• The descendants of a vertex v are those vertices that have v as an ancestor.
• A vertex of a rooted tree is called a leaf if it has no children.
• Vertices that have children are called internal vertices.
• The root is an internal vertex unless it is the only vertex in the graph, in which case
it is a leaf.
• If a is a vertex in a tree, the subtree with a as its root is the subgraph of the tree
consisting of a and its descendants and all edges incident to these descendants.
• The parent of c is b. The children of
g are h, i, and j.
• The siblings of h are i and j.
• The ancestors of e are c, b, and a.
The descendants of b are c, d, and
e.
• The internal vertices are a, b, c, g,
h, and j.
• The leaves are d, e, f, i, k, l, and m.

Subtree of the graph T at g


• Depth and Level: The depth of a node v is the length of the
path from the root to the node v:
• In a rooted tree, a vertex v is said to be at level 𝑙 𝑣 if v is
at a distance 𝑙 𝑣 from the root.
• The set of all nodes at a given depth is sometimes called a
level of the tree. The root node is at depth zero. Thus the
root is at level 0.
• Depth or Height of a tree: The depth or height of a tree is
the length of the path from the root to the deepest node in
the tree. A (rooted) tree with only one node (the root) has
a depth of zero.
• Forest: A forest is an acyclic graph, which is a collection of
trees
Properties of tree
• Every pair of vertices in a tree is connected by one and only
one path.
• (Converse of theorem)If there is one and only one path
between every pair of vertices in a graph G, then G is a
tree.
• A connected graph is a tree if and only if addition of an
edge between any two vertices in the graph creates exactly
one circuit.
• Any tree with two or more vertices contains at least two
pendant vertices.
• A tree with n number of vertices has 𝑛 − 1 number of
edges.
• Converse of theorem)A connected graph with n vertices
and n-1 edges is a tree.
• Minimally connected graph: A connected graph
is said to be minimally connected if the graph
becomes disconnected when one edge is
removed
• A graph is a tree if and only if it is minimally
connected.
Questions
Q: Determine for which value of m or n, the
given graphs are also tree.
1. 𝐾𝑛
2. 𝐾𝑚,𝑛
3. Petersen graph
4. K-regular graph
Spanning Tree
• A tree T is called a spanning tree of a connected graph G if T is a subgraph of G
and if T contains all the vertices of G. In other words, a spanning tree of a
graph G is a spanning subgraph of G that is a tree.
Example
A county's five towns, A through E, are connected by roads
but 2 feet of snow cover them. The county would like to
plow as few roads as possible, so one can travel between
the towns. You can see that H is a subgraph of G containing all
the vertices of G and hence H is a spanning tree of G.
Definition
• A subgraph H of a connected graph G is a spanning tree of G if H
is a tree containing every vertex of G.
• We can see that Se of vertices of G=V(G)=V(H)=set of vertices of
H with lesser edges.
• Two additional spanning trees of the previous graph are

• Hence Spanning tree is not unique for the graph. We may have
more than one spanning trees.
• The spanning tree of a graph need not be
unique.
• Does every connected graph have a
spanning tree? Theorem given below
affirms that it does.
• Theorem: Every connected graph has a
spanning tree.
Finding Spanning tree(Krushal’s algorithm)
• Steps:
• 1. Add any one edge.
• 2. Add the next edge if it is not forming any
circuit.
• 3. Continue Step 2 till you cover all the
vertices of the graph G.
Example
Q: Using Kruskal's algorithm, find spanning
tree for the G.
Spanning tree of G
Q: How many edges does a spanning tree of each graph have?
1. 𝐾𝑛
2. 𝐾𝑚,𝑛
3. Petersen graph
Q: Using Kruskal's algorithm, construct a spanning tree for
each graph, starting at a.
1.

Q:Find a spanning tree for each complete bipartite graph.


Minimum spanning tree
• Weighted graph : A graph is called as weighted graph if each
graph is attached with one value weight.

• Finding a minimal spanning tree in a connected


weighted graph can frequently be useful.
• Example :
A utility company would like to lay pipelines for natural gas
between five towns, a through e, as in Figure 9.25. The
weights (in millions) of the edges represent the cost of
building the various pipelines. They must be laid in such a
way that natural gas can be sent from any town to any
other town, holding construction costs to a minimum. In
other words, the company needs to find a spanning tree
for the weighted graph with the sum of the weights of the
tree's edges at a minimum. Such a tree is a minimal spanning
tree.
• Minimal Spanning Tree : Let G be a
connected weighted graph. The weight of a
spanning tree of G is the sum of the weights
of its edges. A minimal spanning tree of G
weighs the least.
• Several algorithms can find a minimal
spanning tree T of a connected weighted
graph G. Two of them are Kruskal's and
Prim's.
Kruskal's algorithm
Kruskal's algorithm is an extension of his algorithm
presented in the preceding section:
• Arrange the edges in G in non-decreasing order of
their weights.
• Choose an edge in G with the minimum weight.
• Add an edge of least weight to T if it does not
form a cycle with the edges already selected.
• Repeat step 3 until the number of edges selected
is n - 1, where n denotes the number of vertices in
G.
Q: Using Kruskal's algorithm, construct a
minimal spanning tree for each connected
weighted graph.

You might also like