1 / 8

8.3 Representing Relations

8.3 Representing Relations. Rosen 6 th ed., Ch. 8. §8.3: Representing Relations. Some ways to represent n -ary relations: With an explicit list or table of its tuples. With a function from the domain to { T , F } . Or with an algorithm for computing this function.

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 Rosen 6th ed., Ch. 8

  2. §8.3: Representing Relations • Some ways to represent n-ary relations: • With an explicit list or table of its tuples. • With a function from the domain to {T,F}. • Or with an algorithm for computing this function. • Some special ways to represent binary relations: • With a zero-one matrix. • With a directed graph.

  3. Using Zero-One Matrices • To represent a binary relation R:A×B by an |A|×|B| 0-1 matrix MR = [mij], let mij = 1 iff (ai,bj)R. • E.g., Suppose Joe likes Susan and Mary, Fred likes Mary, and Mark likes Sally. • Then the 0-1 matrix representationof the relationLikes:Boys×Girlsrelation is:

  4. Properties of Relations • Reflexivity: A relation R on A x A is reflexive if for all aA, (a,a) R. • Symmetry: A relation R on AxA is symmetric if (x,y)  R implies (y,x)  R. • Anti-symmetry: A relation on A x A is anti-symmetric if (a,b)  R implies (b,a)  R. Or a = b.

  5. Zero-One Reflexive, Symmetric • Terms: Reflexive, symmetric, and antisymmetric. • These relation characteristics are very easy to recognize by inspection of the zero-one matrix. any-thing anything anything any-thing Reflexive:all 1’s on diagonal Symmetric:all identicalacross diagonal Antisymmetric:all 1’s are acrossfrom 0’s

  6. Using Directed Graphs • A directed graph or digraphG=(VG,EG) is a set VGof vertices (nodes) with a set EGVG×VG of edges (arcs,links). Visually represented using dots for nodes, and arrows for edges. Notice that a relation R:A×B can be represented as a graph GR=(VG=AB, EG=R). Edge set EG(blue arrows) Graph rep. GR: Matrix representation MR: Joe Susan Fred Mary Mark Sally Node set VG(black dots)

  7. Digraph Reflexive, Symmetric It is extremely easy to recognize the reflexive/irreflexive/ symmetric/antisymmetric properties by graph inspection.            Reflexive:Every nodehas a self-loop Irreflexive:No nodelinks to itself Symmetric:Every link isbidirectional Antisymmetric:No link isbidirectional These are asymmetric & non-antisymmetric These are non-reflexive & non-irreflexive

  8. Properties of Relations • Transitivity: A relation on A x A is transitive if (a,b)  R and (b,c)  R imply (a,c)  R. Graph??

More Related