8.3 representing relations connection matrices let r be a relation from a = {a 1, a 2,..., a m } to...

13
8.3 Representing Relations Connection Matrices Let R be a relation from A = {a 1 , a 2 , . . . , a m } to B = {b 1 , b 2 , . . . , b n }. Definition: A n m n connection matrix M for R is defined by M ij = 1 if <a i , b j > is in R, = 0 otherwise. • Example: We assume the rows are labeled with the elements of A and the columns are labeled with the elements of B. Let A = {a, b, c} , B = {e, f, g, h}; R = {<a, e>, <c, g>} Then the connection matrix M for R is • Note: the order of the elements of A and B matters 0 1 0 0 0 0 0 0 0 0 0 1 1

Upload: micheal-fish

Post on 14-Dec-2015

217 views

Category:

Documents


2 download

TRANSCRIPT

1

8.3 Representing Relations Connection Matrices

• Let R be a relation fromA = {a1, a2, . . . , am} to B = {b1, b2, . . . , bn}.

• Definition: An m n connection matrix M for R is

defined by Mij = 1 if <ai, bj> is in R, = 0 otherwise.• Example: We assume the rows are labeled with the

elements of A and the columns are labeled with the elements of B. Let A = {a, b, c} ,

B = {e, f, g, h}; R = {<a, e>, <c, g>}• Then the connection matrix M for R is

• Note: the order of the elements of A and B matters

0100

0000

0001

2

Representing Relations• Theorem: Let R be a binary relation on a set A and let

M be its connection matrix. Then• R is reflexive iff Mii = 1 for all i.• R is symmetric iff M is a symmetric matrix: M = MT

• R is antisymetric if Mij = 0 or Mji = 0 for all i ≠ j.

FIGURE 1 The Zero-One Matrix for a Reflexive Relation.

FIGURE 2 The Zero-One Matrices for Symmetric and Antisymmetric Relations.

3

Combining Connection Matrices• Example 3: Suppose that the relation R on a set is

represented by the matrix

• Is R reflexive, symmetric and/or antisymmetric?• Definition: the join of two matrices M1, M2, denoted

M1 Ú M2 , is the component wise boolean ‘or’ of the two

matrices.• Fact: If M1 is the connection matrix for R1 and M2 is the

connection matrix for R2 then the join of M1 and M2 ,

M1 Ú M2 is the connection matrix for R1 R∪ 2 .

110

111

011

RM

4

Combining Connection Matrices• Definition: the meet of two matrices M1, M2, denoted

M1 Ù M2 is the componentwise boolean ‘and’ of the two matrices.

• Fact: If M1 is the connection matrix for R1 and M2 is the connection matrix for R2 then the meet of M1 and M2, M1 Ù M2 is the connection matrix for R1∩R2 .

• Example 4: Suppose that the relations R1 and R2 on a set A are represented by the matrices.

and ,

What are the matrices representing R1 R∪ 2 and R1∩R2 ?

010

001

101

1RM

001

110

101

2RM

5

The Composition• Definition: Let

M1 be the connection matrix for R1

M2 be the connection matrix for R2.

• The boolean product of two connection matrices M1 and M2, denoted M1 Ä M2 , is the connection matrix for the composition of R2 with R1 , R2。 R1.

(M1 Ä M2 )ij = Úk=1

n [(M1 )ik Ù (M2 )kj ]

• Why?

6

The Composition• In order for there to be an arc <x, z> in the composition then there must be and arc <x, y> in R1 and an arc <y, z>

in R2 for some y !• The Boolean product checkes all possible y’s. If at least one such path exists, that is sufficient.• Note: the matrices M1 and M2 must be conformable: the

number of columns of M1 must equal the number of rows

of M2.

• If M1 is m n and M2 is n p then M1 Ä M2 is m p.

The CompositionExample :

7

(M1 Ä M2 )12 = [(M1 )11 Ù (M2 )12 ]Ú[(M1 )12

Ù(M2 )22 ]

Ú[(M1 )13 Ù (M2 )32 ]Ú[(M1)14 Ù (M2 )42 ]

= [0 Ù 0] Ú [1 Ù 1] Ú [0 Ù 0] Ú [0 Ù 1] = 1

8

The Composition• Note:• there is an arc in R1 from node 1 in A to node 2 in B

• there is an arc in R2 from node 2 in B to node 2 in C.

• Hence there is an arc in R2。 R1 from node 1 in A to node 2 in C.

9

Representing Relations Using Digraphs• Definition 1: 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.

• An edge of the form (a, a) is represented using an arc from the vertex a back to itself. Such an edge is called a loop.

10

Representing Relations Using Digraphs• Example 7: The directed graph with vertices a, b, c,

and d, and edges (a, b), (a, d), (b, b), (b, d), (c, a), (c, b), and (d, b) is displayed in Figure 3.

FIGURE 3 The Directed Graph.

11

Representing Relations Using Digraphs• Example 8: 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 {1, 2, 3, 4} is shown in figure 4.

FIGURE 4 The Directed Graph of the Relations R.

12

Representing Relations Using Digraphs• Example 9: What are the ordered pairs in the relation

R represented by the directed graph shown in figure 5?

FIGURE 5 The Directed Graph of the Relations R.

13

Representing Relations Using Digraphs• Example 10: Determine whether the relations for the

directed graphs shown in figure 6 are reflexive, symmetric, antisymmetric, and/or transitive.

FIGURE 6 The Directed Graph of the Relations R and S.