Discrete Structures
Discrete Structures
Introduction
Graphs are simple, however, they are extremely useful mathematical objects. They are
universal in the practical applications of Computer Science. For example:
Graphs
Graphs are made up of a collection of dots that are called vertices and lines connecting
those dots that are called edges. When two vertices are connected by an edge, we say that
they are adjacent.
Definition: A graph is an ordered pair G = (V, E) consisting of a nonempty set V (vertices)
and a set E (edges) of two-element subsets of V.
Definition: A directed graph G is a pair (V, E) where V is a set of vertices (or nodes), and
E V × V is a set of edges. The order of the two connected vertices is important.
Definition: An undirected graph additionally has the property that (u, v) E if and only if
(v, u) E.
Example 1
In a school social gathering, Abel, Bill, Clair, Dan, and Eve were assigned to a group. In
that group, all members are allowed to “discuss” with each other. However, it turns out that
the discussions were between Abel and Clair, Bill and Dan. While Eve discussed with
everyone. Represent this situation with a graph.
Solution
Each person will be represented by a vertex and each discussion will be represented by an
edge. That is, two vertices will be adjacent (there will be an edge between them) if and only
if the people represented by those vertices discussed.
AB
E
C D
From definition of a graph, a graph could be G = (V, E) = ({a, b, c, d}, {{a, b}, {a, c}, {b,
c}, {b, d}, {c, d}}). This graph has four vertices (a, b, c, d) and five edges (the pairs {a,
b}, {a, c}, {b, c}, {b, d}, {c, d}).
Exercise 2
Draw the graph ({a, b, c, d}, {{a, b}, {a, c}, {b, c}, {b, d}, {c, d}}).
In directed graphs, edge (u, v) (starting from node u, ending at node v) is not the same as
edge (v, u). We also allow “self-loops” or “recursive-loops”, i.e., edges of the form (v, v).
Since the edge (u, v) and (v, u) must both be present or missing, we often treat a non-self-
loop edge as an unordered set of two nodes (e.g., {u, v}). A common extension is a
weighted graph, where each edge additionally carries a weight (a real number). The weight
can have a variety of meanings in practice: distance, importance and capacity, to name a
few.
Example 3
G1 = {V1, E1} where V1 = {a, b, c} and E1 = {{a, b}, {a, c}, {b, c}};
G2 = {V2, E2} where V2 = {u, v, w} and E2 = {{u, v}, {u, w}, {v, w}}.
Solution
The two graphs are NOT equal. It is enough to notice that V1, V2 since a V1 but a ∉
V2. However, both of these graphs consist of three vertices with edges connecting every
pair of vertices.
We can clearly see that these graphs are basically the same, so while they are not equal,
they will be isomorphic. This means the renaming of the vertices of one of the graphs and
results in the second graph.
Isomorphic Graphs
we write G1 ≌ G2.
in G2. Two graphs are isomorphic if there is an isomorphism between them. In this case
Example
Decide whether the graphs G1 = {V1, E1} and G2 = {V2, E2} are equal or isomorphic.
V1 = {a, b, c, d}, E1 = {{a, b}, {a, c}, {a, d}, {c, d}} and V2 = {a, b, c, d}, E2 = {{a, b},
{a, c}, {b, c}, {c, d}}.
Solution
The graphs are NOT equal, since {a, d} E1 but {a, d} ∉ E2. However, we can confirm
that both graphs contain the exact same number of vertices and edges. By this, they might
be isomorphic (this is a good start but in most cases, it is not enough).
Let’s try to build an isomorphism. From the definition, let’s try to build a bisection f: V1
→ V2, such that f(a) = b, f(b) = c, f(c) = d and f(d) = a. This is a bisection, but to make
sure that the function is an isomorphism, we must make sure it respects the edge relation.
In G1, the vertices a and b are connected by an edge. In G2, f(a) = b and f(b) = c are
connected by an edge. We are on the right track, however, we have to check the other
three edges. The edge {a, c} in G1 corresponds to {f(a), f(c)} = {b, d}, now we have a
problem here. There is no edge between b and d in G2. Thus f is NOT an isomorphism.
If f is not an isomorphism, it does not mean that there is no isomorphism between G1 and
G2. Let’s draw the graphs and then try to create some match ups (if possible).
It is noticeable in G1 that the vertex a is adjacent to every other vertex. In G2, there is also
a vertex with such property and that is c. Therefore, we can build the bisection g: V1 →
V2 by defining g(a) = c to start with. Next, which vertex should we match with b? In G1,
the vertex b is only adjacent to vertex a. There is exactly one vertex like this in G2, that is
d. Therefore, let g(b) = d. By looking at the last two, we can see that we are free to choose
the matches. Therefore, let go with g(c) = b and g(d) = a (switching these would still work
fine). Finally, let’s check that there is really is an isomorphism between G1 and G2 using
g. We have seen that g is definitely a bisection. Now we have to make sure that the edges
are respected. The four edges in G1 are {a, b}, {a, c}, {a, d}, {c, d}.
Under the proposed isomorphism these become {g(a), g(b)}, {g(a), g(c)}, {g(a), g(d)},
{g(c), g(d)}.
The bisection results in the edges: {c, d}, {c, b}, {c, a}, {b, a}.
These edges are precisely the edges in G2. Thus g is an isomorphism, hence G1 ≌ G2.
Subgraphs
Definition: We say that G′ = (V′, E′) is a subgraph of G = (V, E), and write G′ G,
provided V′ V and E′ E.
Example
Considering the graph G1. Which of the graphs G2, G3 and G4 are subgraphs or induced
subgraphs of G1?
iii. The graph G4 is NOT a subgraph of G1. It might seem like it is, however, if you
look closely, you will realize that vertex e does not exist in G4. Therefore, it is
enough to say that G4 is NOT a subgraph of G1, since {c, f} ∈ E4 but {c, f} ∉ E1
and that we don’t have the required E4 E1.
Bipartite Graphs
A graph is bipartite if the vertices can be divided into two sets, A and B, with no two
vertices in adjacent in A and B. The vertices in A can be adjacent to some or all of the
vertices in B. If each vertex in A is adjacent to all the vertices in B, then the graph is a
complete bipartite graph, and gets a special name: Km,n, where |A| = m and |B| = n.
Complement of a Graph: This operation is used with a single graph. To define this, we
need an analogue of a universal set. In this case, we use the complete graph on the vertex
set of the graph for which we would like to find the complement. Let G = (V, E) be a
subgraph of K|V|, the complete graph on |V| vertices. The complement of G¯ in K|V|, denoted
as G = (V1, El), is the subgraph of K|V| with V1 = V and E1 = K|V| (E) - E.
{n ∈ N: any graph with n vertices has at least two vertices of the same degree}.
Proof: The proof is by induction on the number of vertices n in a graph. Let n o = 2 and T =
(Base step) For no, the only graphs to consider are the graph consisting of two isolated
any v ∈ V.
Let G = (V, E) be a graph with n + 1 vertices where n + 1 ≥ 3. Clearly, 0 ≤ deg(v) ≤ n for
Example 3.4.1: The adjacency matrix 𝐴𝐺1 of the directed graph 𝐺1 is given in Figure 1.
MATRICES AND DETERMINANTS
Introduction
In many analysis, variables are assumed to be related by sets of linear equations. Matrix
algebra provides a clear and concise notation for the formulation and solution of such
problems, many of which would be complicated in conventional algebraic notation. The
concept of determinant is based on that of matrix.
MATRIX
The letters aij stand for real numbers. Note that aij is the element in the ith row and jth
column of the matrix. Thus, the matrix A is sometimes denoted by simplified form as (a ij) or
by {aij} i.e., A = (aij). Matrices are usually denoted by capital letters A, B, C etc. and its
elements by corresponding small letters a, b, c etc.
Order of a Matrix: The order or dimension of a matrix is the ordered pair having as first
component the number of rows and as second component the number of columns in the
matrix. If there are 3 rows and 2 columns in a matrix, then its order is written as (3 × 2) or
(3, 2) which is read as three by two. In general, if m are rows and n are columns of a matrix,
then its order is (m × n).
Example
A= and C .
Types of Matrices
i. Row Matrix and Column Matrix: A matrix consisting of a single row is called
a row matrix or a row vector, whereas a matrix having single column is called a
column matrix or a column vector.
ii. Null or Zero Matrix: A matrix in which each element is „0‟ is called a Null or
Zero matrix. Zero matrices are generally denoted by the symbol O. This
distinguishes zero matrix from the real number 0.
The matrix Omxn has the property that for every matrix A mxn, A + O = O + A =
A
iii. Square matrix: A matrix A having same numbers of rows and columns is called
a square matrix. A matrix A of order m n can be written as A mn. If m = n,
then the matrix is said to be a square matrix. A square matrix of order n n, is
simply written as An. A = and C =.
In general,
is a diagonal matrix if and only if
aij = 0 for i ≠ j, and
for at least one i
aij ≠ 0 =j
2. Scalar Matrix: A diagonal matrix in which all the diagonal elements are same, is
called a scalar matrix i.e.
In general,
Is an identity matrix if and only if
aij = 0 for i ≠ j, and
aij ≠ 1 for i = j.
Thus,
Then A = B because the order of matrices A and B is same and a ij = bij for
every i, j.
Example
Find the values of x, y, z and a which satisfy the matrix equation
Solution
By the definition of equality of matrices, we have:
x + 3 = 0 ……………………………(1)
2y + x = -7 ………………………….(2)
z – 1 = 3 …………………………….(3)
4a – 6 = 2a ………………………….(4)
i. From (1) x = -3,
ii. Put the value of x in (2), we get y = -2,
iii. From (3) z = 4,
iv. From (4) a = 3
If Then
for every matrix Amxn, the matrix -Amxn has the property that A + (-A) = (-A) + A = 0 i.e.,
(-A) is the additive inverse of A. The sum B m-n + (-Amxn) is called the difference of Bmxn
and Amxn and is denoted by Bmxn – Amxn.
Operations on Matrices
Multiplication of a Matrix by a Scalar: If A is a matrix and k is a scalar (constant),
then kA is a matrix whose elements are the elements of A, each multiplied by k.
Let .
Then, C = A + B =
Similarly, the difference A – B of the two matrices A and B is a matrix each element
of which is obtained by subtracting the elements of B from the corresponding
elements of A.
Then, D = A -
Note: The sum or difference of two matrices of different order is not defined. For example,
the sum or difference of a matrices with orders (3 x 2) and (2 x 2) is not defined.
Product of Matrices: Two matrices A and B are said to be conformable for the product AB
if the number of columns of A is equal to the number of rows of B. Then the product matrix
AB has the same number of rows as A and the same number of columns as B.
Thus the product of the matrices Amxp and Bpxn is the matrix (AB)mxn. The elements of AB
are determined as follows:
The element Cij in the ith row and jth column of (AB) mxn is found by cij = ai1b1j + ai2b2j +
ai3b3j + ……….+ ainbnj
For example, let’s consider the matrices:
Since the number of columns of A is equal to the number of rows of B, the product AB is
defined and is given as
Example
Remarks:
If A, B and C are the matrices of order (m x p), (p x q) and (q x n) respectively,
then,
Determinant
The determinant of a matrix is a scalar (number), obtained from the elements of a matrix by
specified, operations, which is characteristic of the matrix. The determinants are defined
only for square matrices. Determinant is denoted by det (A) or |A| for a square matrix A.
= | 𝑎11𝑎22 − 𝑎21𝑎12
𝑎11 𝑎12 13
|𝐴| = | 𝑎21 22 𝑎23 |
𝑎31 32 𝑎33 ………………………….. (1)
The scalars Cij = (-1)i+j Mij are called the cofactor of the element a ij of the
matrix A. The value of the determinant in equation (1) can also be found by its
minor elements or cofactors, as a11M11 – a12M12 + a13M13 Or a11C11 +
a12C12 + a13C13.
Hence, the |A| is the sum of the elements of any row or column multiplied by
their corresponding cofactors. The value of the determinant can be found by
expanding it from any row or column.
Example 3.2.3 find |A| by expansion about (a) the first row (b) the
first
column. Solution 3.2.3. (a) Using the first row
3 2 1
|=|0 1 2|
1 3 4
= 3 |1 2| − 2 | 0 2| + 1 |0 1|
3 4 1 4 1 3
= 3(1.4 – (-2).3) -2(0.4 – 1. -2) +1(0.3 – 1.1)
= 3(4+6) -2(0+2) +1(0-1)
= 30 – 4 – 1
= 25
Solution 3.2.3. (b) Using the first column
3 2 1
|=|0 1 2|
1 3 4
= 3 |1 2| − 0 | 2 1| + 1 |2 1|
3 4 3 4 1 2
= 3(1.4 – (-2).3) - 0(2.4 – 3.1) +1(2.-2 – 1.1)
= 3(4+6) - 0(8 - 2) +1(-4 - 1)
= 30 – 0 – 5
= 25
3.3. Special Matrices
1. Transpose of a Matrix
If A = [aij] is m n matrix, then the matrix of order n m obtained by
interchanging the rows and columns of A is called the transpose of A. It is denoted
At or A. For example,
if then,
2. Symmetric Matrix
A square matrix A is called symmetric if A = At. For example,
if then,
3. Skew Symmetric
A square matrix A is called skew symmetric if A = −At. For example,
If then,
then,
C 5; C 2; C
C 2; C
C 2; C
𝐶 = [−1 2 − 1 ]
5 −2 1
3 −2 3
𝐶 = [−2 2 − 2 ]
5 −1 3
𝑡
1 −1 3
Therefore, Adj (A) = Ct
6. Inverse of a Matrix
Adj (A) =
Example 3.1.7
Solution 3.1.7.
|A| = 0 +2 (–2 +3) – 3(–2 + 3) = 2 –
3 |A| = –1, Hence solution exists.
Cofactor of A are:
So,
Let .
If A is a singular matrix, then of course it has no inverse, and either the system has
no solution or the solution is not unique.
|A| = 3 + 21 – 24 = 0
Since |A| = 0, the solution of the given linear equations does not exist.
Example 3.1.9. Use matrices to find the solution set of
4x + 8y + z = –6
2x – 3y + 2z = 0
x + 7y – 3z = –8
Solution 3.1.9.
|A| = –32 + 48 + 17 = 61
Since |A| 0 then, A-1 exists.
Now since,
X = A-1B, we have
Assignment
1. Write the following matrices in tabular form:
a. A = [aij], where i = 1, 2, 3 and j = 1, 2, 3, 4
b. B = [bij], where i = 1 and j = 1, 2, 3, 4
c. C = [cjk], where j = 1, 2, 3 and k = 1
b. (A + B)(A – B) A2 – B2
3. Write each product as a single matrix
a.
b.
c.
4. , find
a. CB + A2
b. B2 + AC
c. kABC, where k = 2.
5. Find K such that the following matrices are singular
a.
b.
c.
6. Find the solution set of the following system by means of matrices:
a. 2x – 3y = –1 x + 4y = 5
b. x+y=2
2x – z = 1
2y – 3z = –1
c. x – 2y + z = –1
3x + y – 2z = 4
y–z=1
d. –4x + 2y – 9z = 2 3x + 4y + z = 5 x – 3y + 2z = 8
e. x + y – 2z = 3 3x – y + z = 0
3x + 3y – 6z = 8