Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation.

Similar presentations


Presentation on theme: "Section 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation."— Presentation transcript:

1 Section 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation elements or using set builder notation to specify the elements in the relation

2 Representing Relations Using Matrices Let A = {a 1, a 2, …, a n } be a finite set. Then we can represent a relation R over the set A using an n by n matrix: _ _ | e 11 e 12 … e 1n | | e 21 e 22 …e 2n | | … ……… | | e n1 e n2 …e nn | where entry e ij = 1 if (a i, a j )  R and e ij = 0 if (a i, a j )  R. Ex: Let A = {1, 2, 3} and R = {(1,1), (1, 2), (2, 3), (3, 1)}. Then _ _ | 110 | | 001 | | 100 | is the 3 by 3 zero-one matrix that represents the relation R.

3 This representation can be generalized in the obvious way to represent a relation R from A to B where both A and B are finite sets with m and n elements respectively. Then an m by n zero-one matrix can be used to represent the relation R. Ex: Let A = {1, 2, 3}, B = {a, b} and R = {(1,b), (2, a), (2, b)}. Then _ _ | 01 | | 11 | | 00 | is the 3 by 2 zero-one matrix that represents the relation R. We can use the matrix representation to store relations in a computer and efficiently perform certain operations on relations using matrix operations. We can also use the matrix representation of a relation to investigate whether the relation satisfies the various properties introduced in section 7.1.

4 We will concentrate on square matrices since most of the properties we introduced only apply to relations over a set A. _ _ | e 11 e 12 e 13 …e 1n | | e 21 e 22 e 23 …e 2n | | e 31 e 32 e 33 …e 3n | | …………… | | e n1 e n2 e n3 …e nn | Reflexive? Irreflexive? Symmetric? We can also use the matrix representation of a relation to compute the composite of two relations R and S. To compute S  R we simply multiply the matrix representing R with the matrix representing S. Note that this is a boolean matrix multiplication, meaning that the resulting entry can only be 0 or 1. So entries that exceed 1 when multiplied are returned to the value 1 for the resulting matrix.

5 Representing Relations Using Digraphs While the matrix representation is convenient for working with relations in a computer, a digraph representation is a more visually appealing way to represent a relation on a finite set. Let A = {a 1, a 2, …, a 3 } and let R be a relation on A. For the digraph representation of R, we use a labeled dot to represent each element of A. Then for each pair (a j, a k ) that is in R, we draw an arrow coming out of dot a j and that points to dot a k. Ex: Let A = {1, 2, 3, 4} and R = {(1, 2), (2, 1), (2, 2), (3, 4)}. 1   2 3   4

6 Reflexive: The relation represented by a digraph is reflexive if and only if there is a loop at every vertex. Irreflexive: The relation represented by a digraph is irreflexive if and only if there is not a loop at any vertex. Symmetric: The relation represented by a digraph is symmetric if and only if all arrows (other than loops) come in pairs with reverse direction. Antisymmetric: The relation represented by a digraph is antisymmetric if and only if there are no pairs of arrows with reverse direction. Transitive: The relation represented by a digraph is transitive if and only if there is an edge from a to b whenever there is a path from a to b for all nodes a and b.


Download ppt "Section 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation."

Similar presentations


Ads by Google