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

DM - Lecture 07 (1) Part 1

The document discusses two main methods for representing relations: matrices and graphs. It provides examples of using zero-one matrices to represent relations, and how to determine properties of relations from the matrices like reflexive, symmetric, and antisymmetric. It also introduces directed graphs as another way to represent relations, with vertices for elements of the domain and edges for ordered pairs in the relation.

Uploaded by

Hassan Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

DM - Lecture 07 (1) Part 1

The document discusses two main methods for representing relations: matrices and graphs. It provides examples of using zero-one matrices to represent relations, and how to determine properties of relations from the matrices like reflexive, symmetric, and antisymmetric. It also introduces directed graphs as another way to represent relations, with vertices for elements of the domain and edges for ordered pairs in the relation.

Uploaded by

Hassan Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 16

Relations

12/01/23 1
Representing Relations
 Two methods are generally used to represent
relations
 Representing relations using matrices
 Pictorial representation
 Graphs

 Arrow Graphs

 Digraphs

2
Matrix Representation of a Relation
 A relation between finite sets can be represented using
a zero-one matrix

 Let A={a1, a2, …, am} and B={b1, b2, …, bn},

 R can be represented by the zero-one matrix MR = [mij]


with
 mij = 1, if (ai, bj)R, and

 mij = 0, if (ai, bj)R

3
Representing Relations
 Example: Let A = {1,2,3} and B = {x,y}
Let R be a relation from A to B defined as
R = {(1, x), (2, x), (2, y), (3,x)}

 Solution: The matrix MR is given by

12/01/23 4
Representing Relations
 Example: Let A={a1, a2, a3} and B={b1, b2, b3, b4}
Which ordered pairs are in the relation R represented by the
matrix

12/01/23 5
Representing Relations
 Square matrix of a relation can be used for determining whether
the relation has certain properties
 R is reflexive if all the elements on the main diagonal of MR are
equal to 1
 R is symmetric if and only if mji = 1 whenever mij = 1
 R is antisymmetric if mji = 1 with i not equal j then mij = 0

12/01/23 6
Representing Relations

 R is reflexive because all the diagonal elements are equal to 1

 R is symmetric because MR is symmetric

 R is not antisymmetric

12/01/23 7
Representing Relations
 These matrices are symmetric or not?

1 0 1 1 1 1 0 0
0 1 0 0 1 1 0 0
MR   MR  
1 0 0 1 1 1 0 0
   
1 0 1 1 1 1 0 0
symmetric matrix, non-symmetric matrix,
symmetric relation. non-symmetric relation.

12/01/23 8
Representing Relations
 The matrices representing the union and the
intersection of two relations
 To obtain the Union of two zero-one matrices, we apply
the Boolean “or” function to all corresponding elements in
the matrices
 To obtain the intersection of two zero-one matrices, we
apply the Boolean “and” function to all corresponding
elements in the matrices.

12/01/23 9
Representing Relations
 Example: Let the relations R and S be represented
by the matrices
1 0 1  1 0 1 
M R  1 0 0  M S  0 1 1 
0 1 0  1 0 0 

What are the matrices representing RS and RS?


Solution: These matrices are given by
1 0 1  1 0 1 
M RS  M R  M S  1 1 1  M RS  M R  M S  0 0 0 
1 1 0  0 0 0 
12/01/23 10
Representing Relations Using Digraphs

 Definition: A directed graph, or digraph, consists of a


set V of vertices (or nodes) together with a set E of
ordered pairs of elements of V called edges (or arcs)

 The vertex a is called the initial vertex of the edge (a,


b), and the vertex b is called the terminal vertex of this
edge

 We can use arrows to display graphs

12/01/23 11
Representing Relations Using Digraphs
Example: Display the digraph with V = {a, b, c, d},
E = {(a, b), (a, d), (b, b), (b, d), (c, a), (c, b), (d, b)}.

a
b

d c

An edge of the form (b, b) is called a loop.


12/01/23 12
Representing Relations Using Digraphs
 Obviously, we can represent any relation R on a set A by
the digraph with A as its vertices and all pairs (a, b)R as
its edges
 Vice versa, any digraph with vertices V and edges E can
be represented by a relation on V containing all the pairs
in E
 This one-to-one correspondence between relations
and digraphs means that any statement about relations
also applies to digraphs, and vice versa

12/01/23 13
The directed graph of the relation
R = {(1, 1), (1, 3), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2),
(4, 1)} on the set A= {1, 2, 3, 4} is
What are the ordered pairs in the relation R
represented by the directed graph shown below.

R = {(1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (3, 1), (3, 3), (4, 1),
(4, 3)}
Determine whether the relations for the directed
graphs shown below are reflexive, symmetric,
antisymmetric, and/or transitive.

You might also like