0% found this document useful (0 votes)
11 views110 pages

Lec 15

This document is a lecture by Dr. Muhammad Yousuf Tufail on Graph Theory, specifically focusing on the matrix representations of directed graphs. It defines the adjacency matrix for directed graphs and provides examples and solutions for constructing and interpreting these matrices. The lecture illustrates how to derive adjacency matrices from directed graphs and vice versa.

Uploaded by

Ahmer Agro
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 views110 pages

Lec 15

This document is a lecture by Dr. Muhammad Yousuf Tufail on Graph Theory, specifically focusing on the matrix representations of directed graphs. It defines the adjacency matrix for directed graphs and provides examples and solutions for constructing and interpreting these matrices. The lecture illustrates how to derive adjacency matrices from directed graphs and vice versa.

Uploaded by

Ahmer Agro
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/ 110

Graph Theory

Dr. Muhammad Yousuf Tufail

Department of Mathematics
NED University of Engineering & Technology.
https: // dmt. neduet. edu. pk/ node/ 20 Link
‡ Yousuf Tufail ¯ Yousuf Tufail
tufail@neduet.edu.pk

Lecture 15

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 1 / 20


Matrix Representations of Graphs

Definition (Adjacency matrix for directed graph)


Let G be a directed graph with ordered vertices v1 , v2 , ..., vn . The
adjacency matrix of G is the n × n matrix A = aij over the set of
non-negative integers such that aij = the number of arrows from vi to vj
∀i, j = 1, 2, ..., n.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 2 / 20


Matrix Representations of Graphs

Definition (Adjacency matrix for directed graph)


Let G be a directed graph with ordered vertices v1 , v2 , ..., vn . The
adjacency matrix of G is the n × n matrix A = aij over the set of
non-negative integers such that aij = the number of arrows from vi to vj
∀i, j = 1, 2, ..., n.

Example (1)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 2 / 20


Matrix Representations of Graphs

Definition (Adjacency matrix for directed graph)


Let G be a directed graph with ordered vertices v1 , v2 , ..., vn . The
adjacency matrix of G is the n × n matrix A = aij over the set of
non-negative integers such that aij = the number of arrows from vi to vj
∀i, j = 1, 2, ..., n.

Example (1)
Find the adjacency matrices for the following directed graph.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 2 / 20


Matrix Representations of Graphs
Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 . Therefore, first row of the
matrix would be zero.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 . Therefore, first row of the
matrix would be zero. There is a loop over v2 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 . Therefore, first row of the
matrix would be zero. There is a loop over v2 . Therefore, second entry in
the main diagonal (i.e., second row, second column) would be 1.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 . Therefore, first row of the
matrix would be zero. There is a loop over v2 . Therefore, second entry in
the main diagonal (i.e., second row, second column) would be 1. There
are two arrows that are originated from v3 and going to v1 . Therefore, a3,1
would be 2.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 . Therefore, first row of the
matrix would be zero. There is a loop over v2 . Therefore, second entry in
the main diagonal (i.e., second row, second column) would be 1. There
are two arrows that are originated from v3 and going to v1 . Therefore, a3,1
would be 2. In the same manner, rest of the entries can be filled in the
matrix.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 . Therefore, first row of the
matrix would be zero. There is a loop over v2 . Therefore, second entry in
the main diagonal (i.e., second row, second column) would be 1. There
are two arrows that are originated from v3 and going to v1 . Therefore, a3,1
would be 2. In the same manner, rest of the entries can be filled in the
matrix. The required adjacency matrix (with rows (columns) names are
v1 , v2 , v3 ) will be:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20


Matrix Representations of Graphs
Solution
For a:
It is cleared from the given directed graph that there are three vertices
namely v1 , v2 , v3 . Therefore the order of adjacency matrix will be 3 × 3.
There is no arrow that is originated from v1 . Therefore, first row of the
matrix would be zero. There is a loop over v2 . Therefore, second entry in
the main diagonal (i.e., second row, second column) would be 1. There
are two arrows that are originated from v3 and going to v1 . Therefore, a3,1
would be 2. In the same manner, rest of the entries can be filled in the
matrix. The required adjacency matrix (with rows (columns) names are
v1 , v2 , v3 ) will be:

v1 v2 v3
 
v1 0 0 0
Adjacency Matrix = v2  0 1 1 
v3 2 1 0
Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 3 / 20
Matrix Representations of Graphs
Example (2)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 4 / 20


Matrix Representations of Graphs
Example (2)
Draw the directed graph for the following adjacency matrix
 
0 1 1 0
1 1 0 2
Adjacency Matrix =  0 0 1

1
2 1 0 0

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 4 / 20


Matrix Representations of Graphs
Example (2)
Draw the directed graph for the following adjacency matrix
 
0 1 1 0
1 1 0 2
Adjacency Matrix =  0 0 1

1
2 1 0 0

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 4 / 20


Matrix Representations of Graphs
Example (2)
Draw the directed graph for the following adjacency matrix
 
0 1 1 0
1 1 0 2
Adjacency Matrix =  0 0 1

1
2 1 0 0

Solution
Given matrix can be written as:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 4 / 20


Matrix Representations of Graphs
Example (2)
Draw the directed graph for the following adjacency matrix
 
0 1 1 0
1 1 0 2
Adjacency Matrix =  0 0 1

1
2 1 0 0

Solution
Given matrix can be written as:
v1 v2 v3 v4
 
v1 0 1 1 0
v2  1 1 0 2 
Adjacency Matrix = 
 0

v3 0 1 1 
v4 2 1 0 0
Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 4 / 20
Matrix Representation of Graphs

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0. This
implies that v1 is connected to v2 and v3 (i.e., a single arrow will be
directed to each of the vertex v2 and v3 ).

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0. This
implies that v1 is connected to v2 and v3 (i.e., a single arrow will be
directed to each of the vertex v2 and v3 ). In the similarly fashion, all rows
can be defined accordingly.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0. This
implies that v1 is connected to v2 and v3 (i.e., a single arrow will be
directed to each of the vertex v2 and v3 ). In the similarly fashion, all rows
can be defined accordingly. The main diagonal indicates whether or not
the vertices have loops.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0. This
implies that v1 is connected to v2 and v3 (i.e., a single arrow will be
directed to each of the vertex v2 and v3 ). In the similarly fashion, all rows
can be defined accordingly. The main diagonal indicates whether or not
the vertices have loops. 1 (in the main diagonal) indicates a loop over
corresponding vertex and ‘0’ (in the main diagonal) indicates no loop.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0. This
implies that v1 is connected to v2 and v3 (i.e., a single arrow will be
directed to each of the vertex v2 and v3 ). In the similarly fashion, all rows
can be defined accordingly. The main diagonal indicates whether or not
the vertices have loops. 1 (in the main diagonal) indicates a loop over
corresponding vertex and ‘0’ (in the main diagonal) indicates no loop.
Therefore, there should be a loop for v2 and v3 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0. This
implies that v1 is connected to v2 and v3 (i.e., a single arrow will be
directed to each of the vertex v2 and v3 ). In the similarly fashion, all rows
can be defined accordingly. The main diagonal indicates whether or not
the vertices have loops. 1 (in the main diagonal) indicates a loop over
corresponding vertex and ‘0’ (in the main diagonal) indicates no loop.
Therefore, there should be a loop for v2 and v3 . The directed graph is in
the figure below:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix Representation of Graphs

Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0. This
implies that v1 is connected to v2 and v3 (i.e., a single arrow will be
directed to each of the vertex v2 and v3 ). In the similarly fashion, all rows
can be defined accordingly. The main diagonal indicates whether or not
the vertices have loops. 1 (in the main diagonal) indicates a loop over
corresponding vertex and ‘0’ (in the main diagonal) indicates no loop.
Therefore, there should be a loop for v2 and v3 . The directed graph is in
the figure below:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 5 / 20


Matrix representation of Graphs
Definition (Adjacency matrix for Undirected graph)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 6 / 20


Matrix representation of Graphs
Definition (Adjacency matrix for Undirected graph)
Let G be a directed graph with ordered vertices v1 , v2 , ..., vn . The
adjacency matrix of G is the n × n matrix A = aij over the set of
non-negative integers such that aij = the number of edges connecting vi
to vj , ∀i, j = 1, 2, ..., n.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 6 / 20


Matrix representation of Graphs
Definition (Adjacency matrix for Undirected graph)
Let G be a directed graph with ordered vertices v1 , v2 , ..., vn . The
adjacency matrix of G is the n × n matrix A = aij over the set of
non-negative integers such that aij = the number of edges connecting vi
to vj , ∀i, j = 1, 2, ..., n.

Example (3)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 6 / 20


Matrix representation of Graphs
Definition (Adjacency matrix for Undirected graph)
Let G be a directed graph with ordered vertices v1 , v2 , ..., vn . The
adjacency matrix of G is the n × n matrix A = aij over the set of
non-negative integers such that aij = the number of edges connecting vi
to vj , ∀i, j = 1, 2, ..., n.

Example (3)
Find the adjacency matrix for the following graph.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 6 / 20


Matrix representation of Graphs

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’. In the similar manner rest of
the entries can be filled in the adjacency matrix.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’. In the similar manner rest of
the entries can be filled in the adjacency matrix. There are only two loops
in the graph that are at v2 and v4 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’. In the similar manner rest of
the entries can be filled in the adjacency matrix. There are only two loops
in the graph that are at v2 and v4 . Therefore, second and fourth entries in
the main diagonal will be ‘1’.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’. In the similar manner rest of
the entries can be filled in the adjacency matrix. There are only two loops
in the graph that are at v2 and v4 . Therefore, second and fourth entries in
the main diagonal will be ‘1’. Thus the adjacency matrix for the given
graph would be:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’. In the similar manner rest of
the entries can be filled in the adjacency matrix. There are only two loops
in the graph that are at v2 and v4 . Therefore, second and fourth entries in
the main diagonal will be ‘1’. Thus the adjacency matrix for the given
graph would be:

v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20


Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’. In the similar manner rest of
the entries can be filled in the adjacency matrix. There are only two loops
in the graph that are at v2 and v4 . Therefore, second and fourth entries in
the main diagonal will be ‘1’. Thus the adjacency matrix for the given
graph would be:

v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

Remark: Non directed graphs always have symmetric adjacency matrix.


Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 7 / 20
Matrix representation of Graphs

Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4. v1 is connected to v2 and
v4 . Therefore a1,2 , a2,1 , a1,4 , a4,1 will be ‘1’. In the similar manner rest of
the entries can be filled in the adjacency matrix. There are only two loops
in the graph that are at v2 and v4 . Therefore, second and fourth entries in
the main diagonal will be ‘1’. Thus the adjacency matrix for the given
graph would be:

v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

Remark: Non directed graphs always have symmetric adjacency matrix.


Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 8 / 20
Matrix representation of Graphs

Example (4)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 9 / 20


Matrix representation of Graphs

Example (4)
Construct the graph for the following adjacency matrix.
 
0 1 0 1
1 1 2 1
Adjacency Matrix =  0 2 0 0

1 1 0 1

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 9 / 20


Matrix representation of Graphs

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 10 / 20


Matrix representation of Graphs

Solution
Given matrix can be written as:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 10 / 20


Matrix representation of Graphs

Solution
Given matrix can be written as:
v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 10 / 20


Matrix representation of Graphs

Solution
Given matrix can be written as:
v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

As the given matrix is a symmetric matrix,

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 10 / 20


Matrix representation of Graphs

Solution
Given matrix can be written as:
v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

As the given matrix is a symmetric matrix, therefore there are two


possibilities that are

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 10 / 20


Matrix representation of Graphs

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 11 / 20


Matrix representation of Graphs

Solution
Given matrix can be written as:
v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

As the given matrix is a symmetric matrix, therefore there are two


possibilities that are

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 11 / 20


Matrix representation of Graphs

Solution
Given matrix can be written as:
v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

As the given matrix is a symmetric matrix, therefore there are two


possibilities that are(i) either required graph would be directed graph, or

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 11 / 20


Matrix representation of Graphs

Solution
Given matrix can be written as:
v1 v2 v3 v4
 
v1 0 1 0 1
v2  1 1 2 1 
Adjacency Matrix = 
 0

v3 2 0 0 
v4 1 1 0 1

As the given matrix is a symmetric matrix, therefore there are two


possibilities that are(i) either required graph would be directed graph, or
(ii) It is non-directed graph.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 11 / 20


Matrix representation of Graphs

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows. Another fact is:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows. Another fact is: v2
and v4 are also connected to v1 due to the symmetric nature of a
matrix.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows. Another fact is: v2
and v4 are also connected to v1 due to the symmetric nature of a
matrix. In the similar fashion rest of the edges can be computed.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows. Another fact is: v2
and v4 are also connected to v1 due to the symmetric nature of a
matrix. In the similar fashion rest of the edges can be computed. The
entries in the main diagonal are 0, 1, 0, 1.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows. Another fact is: v2
and v4 are also connected to v1 due to the symmetric nature of a
matrix. In the similar fashion rest of the edges can be computed. The
entries in the main diagonal are 0, 1, 0, 1. Therefore, v2 and v4 will
have direction loop over them.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows. Another fact is: v2
and v4 are also connected to v1 due to the symmetric nature of a
matrix. In the similar fashion rest of the edges can be computed. The
entries in the main diagonal are 0, 1, 0, 1. Therefore, v2 and v4 will
have direction loop over them. Thus, the required directed graph is:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1. Therefore, v1 is
connected to v2 and v4 through direction arrows. Another fact is: v2
and v4 are also connected to v1 due to the symmetric nature of a
matrix. In the similar fashion rest of the edges can be computed. The
entries in the main diagonal are 0, 1, 0, 1. Therefore, v2 and v4 will
have direction loop over them. Thus, the required directed graph is:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 12 / 20


Matrix representation of Graphs

For non-directed graph:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 13 / 20


Matrix representation of Graphs

For non-directed graph:


I leave the explanation for you.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 13 / 20


Matrix representation of Graphs

For non-directed graph:


I leave the explanation for you. The required non-directed graph is:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 13 / 20


Matrix representation of Graphs

For non-directed graph:


I leave the explanation for you. The required non-directed graph is:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 13 / 20


Definition (Tree)
A graph is said to be circuit-free if, and only if, it has no circuits. A graph
is called a tree if, and only if, it is circuit-free and connected. A trivial tree
is a graph that consists of a single vertex. A graph is called a forest if, and
only if, it is circuit-free and not connected.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 14 / 20


Definition (Tree)
A graph is said to be circuit-free if, and only if, it has no circuits. A graph
is called a tree if, and only if, it is circuit-free and connected. A trivial tree
is a graph that consists of a single vertex. A graph is called a forest if, and
only if, it is circuit-free and not connected.

Example

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 14 / 20


Definition (Tree)
A graph is said to be circuit-free if, and only if, it has no circuits. A graph
is called a tree if, and only if, it is circuit-free and connected. A trivial tree
is a graph that consists of a single vertex. A graph is called a forest if, and
only if, it is circuit-free and not connected.

Example
Check whether or not the following graphs are trees. Justify your answer.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 14 / 20


Definition (Tree)
A graph is said to be circuit-free if, and only if, it has no circuits. A graph
is called a tree if, and only if, it is circuit-free and connected. A trivial tree
is a graph that consists of a single vertex. A graph is called a forest if, and
only if, it is circuit-free and not connected.

Example
Check whether or not the following graphs are trees. Justify your answer.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 14 / 20


Solution
For a:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Solution
For a:
The given graph is connected as there is always a walk between any two
vertices.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Solution
For a:
The given graph is connected as there is always a walk between any two
vertices. Further we con not construct any circuit (i.e., a closed walk in
which edges are not repeated).

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Solution
For a:
The given graph is connected as there is always a walk between any two
vertices. Further we con not construct any circuit (i.e., a closed walk in
which edges are not repeated). Therefore the given graph is a tree.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Solution
For a:
The given graph is connected as there is always a walk between any two
vertices. Further we con not construct any circuit (i.e., a closed walk in
which edges are not repeated). Therefore the given graph is a tree.
For b:

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Solution
For a:
The given graph is connected as there is always a walk between any two
vertices. Further we con not construct any circuit (i.e., a closed walk in
which edges are not repeated). Therefore the given graph is a tree.
For b:
The given graph is connected but there is a circuit in the graph which is
shown in the figure below.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Solution
For a:
The given graph is connected as there is always a walk between any two
vertices. Further we con not construct any circuit (i.e., a closed walk in
which edges are not repeated). Therefore the given graph is a tree.
For b:
The given graph is connected but there is a circuit in the graph which is
shown in the figure below.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Solution
For a:
The given graph is connected as there is always a walk between any two
vertices. Further we con not construct any circuit (i.e., a closed walk in
which edges are not repeated). Therefore the given graph is a tree.
For b:
The given graph is connected but there is a circuit in the graph which is
shown in the figure below.

As the given graph is not circuit free. There it doesn’t qualify the
definition of tree.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 15 / 20


Definition (Rooted tree)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 16 / 20


Definition (Rooted tree)
A rooted tree is a tree in which there is one vertex that is distinguished
from the others and is called the root. The level of a vertex is the number
of edges along the unique path between it and the root. The height of a
rooted tree is the maximum level of any vertex of the tree. Given the root
or any internal vertex v of a rooted tree, the children of v are all those
vertices that are adjacent to v and are one level farther away from the root
than v. If w is a child of v, then v is called the parent of w, and two
distinct vertices that are both children of the same parent are called
siblings. Given two distinct vertices v and w, if v lies on the unique path
between w and the root, then v is an ancestor of w and w is a descendant
of v.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 16 / 20


Definition (Rooted tree)
A rooted tree is a tree in which there is one vertex that is distinguished
from the others and is called the root. The level of a vertex is the number
of edges along the unique path between it and the root. The height of a
rooted tree is the maximum level of any vertex of the tree. Given the root
or any internal vertex v of a rooted tree, the children of v are all those
vertices that are adjacent to v and are one level farther away from the root
than v. If w is a child of v, then v is called the parent of w, and two
distinct vertices that are both children of the same parent are called
siblings. Given two distinct vertices v and w, if v lies on the unique path
between w and the root, then v is an ancestor of w and w is a descendant
of v.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 16 / 20


Examples

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 17 / 20


Examples
Example (Ex. 10.6, Q. 2)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 17 / 20


Examples
Example (Ex. 10.6, Q. 2)
Consider the tree shown below with root v0 . a. What is the level of v8 ? b.
What is the level of v0 ? c. What is the height of this rooted tree? d.
What are the children of v10 ? e. What is the parent of v5 ? f. What are
the siblings of v1 ? g. What are the descendants of v12 ?

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 17 / 20


Examples

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 . It travelled three edges along the away. Therefore the level of
v8 is 3.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 . It travelled three edges along the away. Therefore the level of
v8 is 3.
(c). v18 and v19 are most furthest from their root.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 . It travelled three edges along the away. Therefore the level of
v8 is 3.
(c). v18 and v19 are most furthest from their root. The levels of v18 and
v19 are 5.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 . It travelled three edges along the away. Therefore the level of
v8 is 3.
(c). v18 and v19 are most furthest from their root. The levels of v18 and
v19 are 5. Thus the hight of this rooted tree is 5.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 . It travelled three edges along the away. Therefore the level of
v8 is 3.
(c). v18 and v19 are most furthest from their root. The levels of v18 and
v19 are 5. Thus the hight of this rooted tree is 5.
(d). Children of v10 are v14 , v15 and v16 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 . It travelled three edges along the away. Therefore the level of
v8 is 3.
(c). v18 and v19 are most furthest from their root. The levels of v18 and
v19 are 5. Thus the hight of this rooted tree is 5.
(d). Children of v10 are v14 , v15 and v16 .
(f). v1 and v2 are siblings.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Examples

Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 . It travelled three edges along the away. Therefore the level of
v8 is 3.
(c). v18 and v19 are most furthest from their root. The levels of v18 and
v19 are 5. Thus the hight of this rooted tree is 5.
(d). Children of v10 are v14 , v15 and v16 .
(f). v1 and v2 are siblings.
(g). Descendants of v12 are v17 , v18 and v19 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 18 / 20


Definition
Spanning tree

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example
Find all spanning tree for the following graph.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example
Find all spanning tree for the following graph.

Solution

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example
Find all spanning tree for the following graph.

Solution
The definition of tree says that it should be circuit free.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example
Find all spanning tree for the following graph.

Solution
The definition of tree says that it should be circuit free. There is one
circuit in the graph which is v1 v2 v4 v1 .

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example
Find all spanning tree for the following graph.

Solution
The definition of tree says that it should be circuit free. There is one
circuit in the graph which is v1 v2 v4 v1 . Removing any of the edge will
make the graph circuit free.

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example
Find all spanning tree for the following graph.

Solution
The definition of tree says that it should be circuit free. There is one
circuit in the graph which is v1 v2 v4 v1 . Removing any of the edge will
make the graph circuit free. Thus the possible spanning trees are

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Definition
Spanning treeA spanning tree for a graph G is a subgraph of G that
contains every vertex of G and is a tree.

Example
Find all spanning tree for the following graph.

Solution
The definition of tree says that it should be circuit free. There is one
circuit in the graph which is v1 v2 v4 v1 . Removing any of the edge will
make the graph circuit free. Thus the possible spanning trees are

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 19 / 20


Problems:
Ex. 10.1 Q.1 — Q.4
Q.8,Q.9, Q.17 — Q.25, Q. 36, Q. 27 (Hint: The Hand shake Theorem)
Ex. 10.2 (Q1.–Q.5, Q. 8–Q. 17, Q.22)
Ex. 10.3 (P. no: 673, 674) Q. 1—Q. 11
Ex. 10.7 (Q. 1–Q. 4)
Ex. 10.6 (Q. 1, Q. 2)

Dr. Muhammad Yousuf Tufail (NED Uni.) Graph Theory Lecture 15 20 / 20

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy