1 / 15

Representing Relations - Matrix and Graph Representations

Learn about different ways to represent relations, including using zero-one matrices and directed graphs. Understand the properties of reflexive, symmetric, and antisymmetric relations.

mirellar
Download Presentation

Representing Relations - Matrix and Graph Representations

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. §7.3 Representing Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael P. Frank’s Course Based on the TextDiscrete Mathematics & Its Applications(5th Edition)by Kenneth H. Rosen

  2. §7.3: Representing Relations • Some ways to represent n-ary relations: • With a list of tuples. • With a function from the domain to {T,F}. • Special ways to represent binary relations: • With a zero-one matrix. • With a directed graph.

  3. Why bother with alternative representations? Is one not enough? • One reason: some things are easier using one representation, some things are easier using another It’s often worth playing around with different representations!

  4. Connection or (Zero-One) Matrices Let R be a relation from A = {a1, a2, . . . , am} to B = {b1, b2, . . . , bn}. Definition: An m x n connection matrix M for R is defined by Mij = 1 if <ai, bj> is in R, Mij = 0 otherwise.

  5. 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:

  6. Special case 1-0 matrices for a relation on A (that is, R:A×A) • Convention: rows and columns list elements in the same order

  7. 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.

  8. Zero-One Reflexive, Symmetric • Recall: Reflexive, irreflexive,symmetric, and asymmetric relations. • These relation characteristics are very easy to recognize by inspection of the zero-one matrix. any-thing any-thing anything anything any-thing any-thing Reflexive:only 1’s on diagonal Irreflexive:only 0’s on diagonal Symmetric:all identicalacross diagonal Asymmetric:all 1’s are acrossfrom 0’s

  9. 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). Visually represented using dots for nodes, and arrows for edges. 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)

  10. Digraph Reflexive, Symmetric It is 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 Asymmetric:No link isbidirectional These are not symmetric & not asymmetric These are non-reflexive & non-irreflexive

  11. Obvious questions: Given the connection matrix for two relations, how does one find the connection matrix for • The complement? • The symmetric difference?

  12. Example

  13. Question:

More Related