Download presentation

Presentation is loading. Please wait.

Published byDavon Moorefield Modified over 2 years ago

1
1 Section 7.3 Representing relations (part 1: matrices)

2
2 Representing relations We have already seen that relations between finite sets can be represented using lists of ordered pairs zero-one matricesTo represent relations in computer programs, zero-one matrices are usually employed Directed graphsDirected graphs provide pictorial representations of relations, and are useful in determining some of their properties

3
3 Matrices matrix rows columnsA matrix is a rectangular array of numbers arranged in horizontal rows and vertical columns Each entry in a matrix can be designated using subscripts representing the entry’s row and column: the element at row i, column j of matrix A would be designated a ij The entire matrix A is often represented with the abbreviation [a ij ]

4
4 Square matrices The size of a matrix is usually represented as m x n, with m representing the number of rows and n the number of columns If m=n, then matrix A is a square matrix

5
5 Examples The matrix at the right is a 4x3 matrix; the values in row 1 are 1 (at column 1), through 4 (at column 4). The value of a 23 is 7. main diagonal In the square matrix at the right, the elements a 11, a 22 and a 33 form the main diagonal of the matrix.

6
6 Transpose of a matrix transposeIf A = [a ij ] is an m x n matrix, then the transpose of A is the n x m matrix A T = [a T ij ] We can obtain A T by interchanging the rows and columns of A The transpose of a transpose is the original matix: (A T ) T = A

7
7 Boolean matrix A zero-one, or Boolean matrix, is a matrix consisting of binary digits Such a matrix can be used to represent a relation between finite sets A relation R from set A to set B can be represented by M R = [m ij ] where –m ij = 1 if (a i, b j ) R –m ij = 0 if (a i, b j ) R

8
8 Example Suppose set A = {a, b, c, d} and set B = {a, c, d} and relations from A to B R 1 = {(a,a), (a,c), (b,d), (d,d)} and R 2 = {(a,c), (b,d), (c,a), (c,d), (d,a), (d,c)}

9
9 Operations on Boolean matrices Suppose A=[a ij ] and B=[b ij ] are Boolean matrices and are the same size joinThe join of A and B is matrix C=[c ij ], represented by A V B: –c ij = 1 if a ij = 1 or b ij =1 –c ij = 0 if both a ij and b ij are 0 meetThe meet of A and B is matrix D=[d ij ], represented by A ^ B: –d ij = 1 if a ij = b ij = 1 –d ij = 0 if either a ij or b ij = 0

10
10 Join and meet: example

11
11 Boolean product of matrices The Boolean product of m x p matrix A and p x n matrix B, denoted A B, is the m x n matrix C = [c ij ] defined by: –c ij = 1 if a ik = 1 and b kj =1 for some k between 1 and p –c ij = 0 otherwise

12
12 Finding the Boolean product For any i and j, c ij C = A B can be computed as follows: –Select row i of A and column j of B and arrange them side by side –Compare corresponding entries; if even a single pair of corresponding entries consists of 2 1’s, then c ij = 1 – if not, then c ij = 0

13
13 Finding Boolean product

14
14 Example

15
15 Matrix of a relation on a set … is a square matrix … can be used to determine certain properties of the relation

16
16 Reflexivity A relation R on set A is reflexive if (a,a) R whenever a A So R is reflexive if m 11 =1, m 22 =1 … m nn =1 In other words, R is reflexive if all elements on the main diagonal of M R = 1

17
17 Symmetry Any relation R is symmetric if (a,b) R implies that (b,a) R A relation R on set A = [a ij ] is symmetric if and only if (a j,a i ) R whenever (a i,a j ) R In matrix M R, we can determine R is symmetric if and only if m ij = m ji for all pairs i, j, with i = 1 … n and j = 1 … n In other words, R is symmetric if and only if M R = (M R ) T

18
18 Antisymmetry A relation R is antisymmetric if and only if (a,b) R and (b,a) R imply that a=b A matrix of an antisymmetric relation has the property that: –If m ij = 1, then m ji = 0 if i j –Or, if i j, then either m ij or m ji = 0 (the other could be 0 or 1)

19
19 Example …see the blackboard; see also exercise 7, p 495

20
20 Representing unions and intersections The Boolean matrix operations join and meet can be used to find matrices representing the union and intersection of two relations Suppose R 1 and R 2 are relations on set A; then they are represented by matrices M R1 and M R2 The matrix representing the intersection of R 1 and R 2 has a 1 in the positions where both M R1 and M R2 have a 1; the matrix representing their union would have a 1 where either has a 1: M R1 R2 = M R1 M R2 M R1 R2 = M R1 M R2

21
21 Example See, again, the blackboard …

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google