Discrete Structure Complex Engineering Problem: Submitted To

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Discrete Structure Complex Engineering Problem

Dr. A. Q. khan Institute of Computer Science & Information Technology

DISCRETE STRUCTURE
COMPLEX ENGINEERING PROBLEM
Submitted to:
Sir Zafar Iqbal
Name:
Esha Baig
Registration no:
UET-18F-BSCE-18
Department:
BSCE
Semester:
4
Date:
1st June, 2020
Day:
Monday

0|Page
Discrete Structure Complex Engineering Problem

Problem Statement:-
Let R be the relation with directed graph shown in Figure 1. Let a, b, c, d be a listing of the
elements of the set. Solve the matricesW0, W1, W2, W3, and W4. The matrix W4 is the
transitive a b closure of R. (Cognitive, C3)

FIGURE 1 A Directed Graph.

Deliverables:

1. Relation
2. Matrices

Solution
I solve this problem using Warshall’s Algorithm. Let we know about
Warshall’s Algorithm.

Warshall’s Algorithm

Warshall’s algorithm, named after Stephen Warshall, who described this algorithm
in 1960, is an efficient method for computing the transitive closure of a relation. Algorithm
1 can find the transitive closure of a relation on a set with n elements using 2n 3(n − 1) bit
operations. However, the transitive closure can be found by Warshall’s algorithm using
only 2n3 bit operations.
Suppose that R is a relation on a set with n elements. Let v 1, v2,..., vn be an arbitrary
listing of these n elements. The concept of the interior vertices of a path is used in
Warshall’s algorithm. If a, x1, x2,...,xm−1, b is a path, its interior vertices are x1, x2,...,xm−1,
that is, all the vertices of the path that occur somewhere other than as the first and last
vertices in the path. For instance, the interior vertices of a path a, c, d, f, g, h, b, j in a
directed graph are c, d, f, g, h, and b. The interior vertices of a, c, d, a, f, b are c, d, a, and f .
(Note that the first vertex in the path is not an interior vertex unless it is visited again by

1|Page
Discrete Structure Complex Engineering Problem

the path, except as the last vertex. Similarly, the last vertex in the path is not an interior
vertex unless it was visited previously by the path, except as the first vertex.) Warshall’s
algorithm is based on the construction of a sequence of zero–one matrices. These
matrices are W0, W1,...,Wn, where W0 = MR is the zero–one matrix of this relation, and W k =
[w(k) ij ], where w(k) ij = 1 if there is a path from v i to vj such that all the interior vertices
of this path are in the set {v1, v2,..., vk} (the first k vertices in the list) and is 0 otherwise.
(The first and last vertices in the path may be outside the set of the first k vertices in the
list.) Note that Wn = MR∗ , because the (i, j )th entry of MR∗ is 1 if and only if there is a path
from vi to vj , with all interior vertices in the set {v 1, v2,..., vn} (but these are the only
vertices in the directed graph).

Solution of this problem:-


Let v1 = a, v2 = b, v3 = c, and v4 = d. W0 is the matrix of the relation. Hence,

0001
W0 =
[ ]
1010
1001
0010

W1 has 1 as its (i, j )th entry if there is a path from v i to vj that has only v1 = a as an interior
vertex. Note that all paths of length one can still be used because they have no interior
vertices. Also, there is now an allowable path from b to d, namely, b, a, d. Hence,

0001
W1 =
[ ]
1011
1001
0010

W2 has 1 as its (i, j )th entry if there is a path from v i to vj that has only v1 = a and/or v2 =
b as its interior vertices, if any. Because there are no edges that have b as a terminal
vertex, no new paths are obtained when we permit b to be an interior vertex. Hence, W 2 =
W1 .

W3 has 1 as its (i, j )th entry if there is a path from vi to vj that has only v1 = a, v2 = b, and/or
v3 = c as its interior vertices, if any. We now have paths from d to a, namely, d, c, a, and
from d to d, namely, d, c, d. Hence,

2|Page
Discrete Structure Complex Engineering Problem

0001
W3 =
[ ]
1011
1001
1011

Finally, W4 has 1 as its (i, j )th entry if there is a path from v i to vj that has v1 = a, v2 = b, v3 =
c, and/or v4 = d as interior vertices, if any. Because these are all the vertices of the graph,
this entry is 1 if and only if there is a path from vi to vj . Hence,

10 1 1
W4 =
[ ]
10 1 1
10 1 1
10 1 1

This last matrix, W4, is the matrix of the transitive closure.

THE END

3|Page

You might also like