Lec 15
Lec 15
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
Example (1)
Example (1)
Find the adjacency matrices for the following directed graph.
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)
Solution
Solution
Given matrix can be written as:
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
Solution
All the entries in the first row (in adjacency matrix) are 0, 1, 1, 0.
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 ).
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.
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.
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.
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 .
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:
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:
Example (3)
Example (3)
Find the adjacency matrix for the following graph.
Solution
Solution
It is cleared from the given graph that the four vertices are used.
Solution
It is cleared from the given graph that the four vertices are used.
Therefore the size of the matrix will be 4 × 4.
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 .
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’.
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.
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 .
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’.
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:
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
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
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
Example (4)
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
Solution
Solution
Given matrix can be written as:
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
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
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
Solution
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
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
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
Solution
Solution
For directed graph:
Solution
For directed graph:
All the entries in the first row are 0, 1, 0, 1.
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.
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:
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.
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.
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.
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.
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:
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:
Example
Example
Check whether or not the following graphs are trees. Justify your answer.
Example
Check whether or not the following graphs are trees. Justify your answer.
As the given graph is not circuit free. There it doesn’t qualify the
definition of tree.
Solution
Solution
(a). It is cleared from the figure that the walk between v8 and the root v0
is v8 v5 v1 v0 .
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.
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.
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.
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.
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 .
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.
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 .
Example
Example
Find all spanning tree for the following graph.
Example
Find all spanning tree for the following graph.
Solution
Example
Find all spanning tree for the following graph.
Solution
The definition of tree says that it should be circuit free.
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 .
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.
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
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