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

Graph Theory Lecture 9 and 10

The document discusses different ways to represent graphs and trees mathematically. It defines acyclic graphs, trees, forests and their properties. Trees have n-1 edges and at least two leaves. Forests consist of disconnected trees. Minimum spanning trees connect all vertices with minimum cost. Common algorithms to find minimum spanning trees are Kruskal's and Prim's algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Graph Theory Lecture 9 and 10

The document discusses different ways to represent graphs and trees mathematically. It defines acyclic graphs, trees, forests and their properties. Trees have n-1 edges and at least two leaves. Forests consist of disconnected trees. Minimum spanning trees connect all vertices with minimum cost. Common algorithms to find minimum spanning trees are Kruskal's and Prim's algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Acyclic Graph, Trees, Forests

Graph Representations
• In graph theory, a graph representation is a technique to store graph
into the memory of computer.
• To represent a graph, we just need the set of vertices, and for each
vertex the neighbors of the vertex. If it is a weighted graph, then the
weight will be associated with each edge.
• There are different ways to optimally represent a graph, depending
on the density of its edges, type of operations to be performed and
ease of use.
Adjacency matrix
• Let G = (V, E), |V| = n and |E|=m
• The adjacency matrix of G written A(G), is the n-by-n matrix in which
entry ai,j is the number of edges in G with endpoints {vi, vj}.
• Example
w w x y z
b w 0 1 1 0
y z x 1 0
a c 2 0
e y 1 2 0 1
x d
z 0 0 1 0
Undirected graph
Directed graph representation

Note: In the above examples, 1 represents an edge from row vertex to column vertex, and 0
represents no edge from row vertex to column vertex.
Undirected weighted graph representation
Adjacency List
• Adjacency list is a linked representation.
• In this representation, for each vertex in the graph, we maintain the
list of its neighbors. It means, every vertex of the graph contains list of
its adjacent vertices.
• We have an array of vertices which is indexed by the vertex number
and for each vertex v, the corresponding array element points to
a singly linked list of neighbors of v.
Example
Incidence Matrix
• Let G = (V, E), |V| = n and |E|=m
• The incidence matrix M(G) for an undirected graph is the n-by-m
matrix in which entry mi,j is 1 if vi is an endpoint of ej and otherwise is
0.
w a b c d e
b w 1 1 0 0 0
y
a c z x 1 0 1 1 0
e
d
y 0 1 1 1 1
x
z 0 0 0 0 1
Directed graph representation
• The incidence matrix M(G) for a directed graph is the n-by-m matrix
in which entry mi,j =1 if edge ej directed from the vertex vi , mi,j = -1 if
edge ej directed to the vertex vi and otherwise is 0.
Acyclic Graph
• A graph not containing any cycle in it is called as an acyclic graph.
Tree
• A tree is a connected acyclic graph.
• A leaf (or pendant vertex ) is a vertex of degree 1.
Forest
• A forest is an acyclic graph in which each connected component is a
tree.

• A tree is a connected forest, and every component of a forest is a


tree. A graph with no cycles has no odd cycles; hence trees and
forests are bipartite graph
Theorem: Every tree with n (≥ 2)vertices has
at least two leaves
Proof:
• A connected graph with at least two vertices has an edge.
• In an acyclic graph, an endpoint of a maximal nontrivial path has no
neighbor other than its neighbor on the path.
• Hence the endpoints of such a path are leaves.
Theorem: Every tree with n vertices has
exactly n-1 edges
Mathematical Induction
Mathematical Induction is a mathematical technique which is used to prove a
statement, a formula or a theorem is true for every natural number.
• The technique involves two steps to prove a statement, as stated below −
Step 1(Base step) − It proves that a statement is true for the initial value.
Step 2(Inductive step) − It proves that if the statement is true for the number n,
then it is also true for number n+1.
How to Do It
Step 1 − Consider an initial value for which the statement is true. It is to be shown
that the statement is true for n = initial value.
Step 2 − Assume the statement is true for any value of n = k. Then prove the
statement is true for n = k+1. We actually break n = k+1 into two parts, one part is n
= k (which is already proved) and try to prove the other part.
Theorem: In a forest with v vertices and k
components, the number of edges are v-k
Proof: Let a graph G has 𝑇1 , 𝑇2 , …, 𝑇𝑘 components and all components
are tree.
Also assume that 𝑇1 is tree of 𝑣1 vertices, 𝑇2 is tree of 𝑣2 vertices…
Theorem
• The following statements are equivalent for given G=(V,E)
(a) G is a tree
(b) G is a connected graph has exactly |v|-1 edges
(c) G is an acyclic graph and has exactly |v|-1 edges
(d) Every two vertices of G are joined by a unique path.
Minimal Connected
• Definition: A graph is said to be minimally connected if removal of any
one edge from it disconnects the graph. Clearly, a minimally
connected graph has no cycles.
Theorem: A graph is a tree if and only if it is
minimally connected.
Proof:
• Let the graph G be minimally connected. Then G has no cycles and
therefore is a tree.
• Conversely, let G be a tree. Then G contains no cycles and deletion of
any edge from G disconnects the graph. Hence G is minimally
connected.
Spanning trees
Minimum spanning tree (MST)
• The cost of the spanning tree is the sum of the weights of all the
edges in the tree.
• There can be many spanning trees for a given graph.
• Minimum spanning tree (MST) is the spanning tree of G for which the
cost is minimum among all the spanning trees.
• There also can be many minimum spanning trees. (only if duplicate
weights in graph)
• There are two algorithms for finding the Minimum Spanning Tree:
• Kruskal’s Algorithm
• Prim’s Algorithm
Kruskal’s Algorithm
Prim’s Algorithm

You might also like