1 / 13

8.3 Representing Relations

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.

remedy
Download Presentation

8.3 Representing Relations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 8.3 Representing Relations Connection Matrices • Let R be a relation from A = {a1, a2, . . . , am} to B = {b1, b2, . . . , bn}. • Definition: Anm 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

  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 iffMii = 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∪R2 .

  4. Combining Connection Matrices • Definition: the meet of two matrices M1, M2, denotedM1Ù M2is the componentwiseboolean ‘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 R2ona set A are represented by the matrices. and , What are the matrices representing R1∪R2 and R1∩R2?

  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 thecomposition of R2 with R1 , R2。R1. (M1Ä M2 )ij= Úk=1n [(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 R2for 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.

  7. The Composition (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 Example :

  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.

More Related