Docsity

Representing Relations: Matrices and Directed Graphs, Slides of Discrete Mathematics

Partial preview of the text

Download Representing Relations: Matrices and Directed Graphs and more Slides Discrete Mathematics in PDF only on Docsity!

1

Representing Relations

2

In this slide set…

• Matrix review

• Two ways to represent relations – Via matrices

  • Via directed graphs

4

Matrix transposition

  • Given a matrixthe matrix obtained by switching the columns and rows M , the transposition of M , denoted M t^ , is of M
  • In a “square” matrix, the maindiagonal stays unchanged

M =  41 52 63 

M^51627384

M^ t^14 

M^ t^21651091413

5

Matrix join

• AOR on each relative entry of the matrices join of two matrices performs a Boolean

  • – Matrices must be the same sizeDenoted by the or symbol: ∨

7

Matrix Boolean product

  • Amultiplication Boolean product of two matrices is similar to matrix
    • Instead of the sum of the products, it’s the conjunction (and) ofthe disjunctions (ors)
    • Denoted by the or symbol:

c 1 (^) , 1 = a 1 , 1 * b 1 , 1 + a 1 , 2 * b 2 , 1 + a 1 , 3 * b 3 , 1 + a 1 , 4 * b 4 , 1 c 1 (^) , 1 = a 1 , 1 ∧ b 1 , 1 ∨ a 1 , 2 ∧ b 2 , 1 ∨ a 1 , 3 ∧ b 3 , 1 ∨ a 1 , 4 ∧ b 4 , 1



⋅

8

Relations using matrices

• List the elements of setsparticular order A and B in a

  • Order doesn’t matter, but we’ll generally useascending order

• Create a matrix M R =[^ mij ]

mij = (^) ^10 ifif(( aaii ,, bbjj ))∈∉ RR

10

Relations using matrices

• What is it good for? – It is how computers view relations

  • Very easy to view relationship properties^ •^ A 2-dimensional array

• We will generally consider relations on asingle set

  • In other words, the domain and co-domain arethe same set
  • And the matrix is square

11

Reflexivity

  • Consider a reflexive relation: – One which every element is related to itself ≤
    • Let A = { 1, 2, 3, 4, 5 }

M

Ifdiagonal is all 1’s, a the center (main)

relation is reflexive

13

M

Symmetry

  • Consider an symmetric relation – One which if a is related to b then R b is related to a for
    • all (Let A = { 1, 2, 3, 4, 5 } a,b )
      • If, forthe equal to the value in every value, it is itsthen transposed the relation position, is symmetric

14

M

Asymmetry

  • Consider an asymmetric relation: < – One which if a is related to b then b is not related to a
    • for all (Let A = { 1, 2, 3, 4, 5 } a,b ) •^ If, for every value and thetransposed value position,in itsif theythen arethe notrelation both 1,is
  • asymmetricAn asymmetric relation
  • must also be irreflexiveThus, the main diagonal must be all 0’sDocsity.com

16

Transitivity

  • Consider an transitive relation: – One which if a is related to b and ≤ b is related to c then -^ a Let A = { 1, 2, 3, 4, 5 }^ is related to^ c^ for all ( a,b ), ( b,c ) and ( a,c )

M

  • If, for every spot (and ( b,c ) that each a,b ) have a 1, there is a 1at ( a,c ), then the relation is transitive
  • Matricesthis property easily don’t show

17

Combining relations: via Boolean operators

  • Let:
  • Join:
  • Meet:

M R^101

M S^101

M R  S M R M S^101

M R  S M R M S^101

19

Representing relations using directed graphs

  • A directed graph consists of: – A set V of vertices (or nodes)
    • – A setIf ( a, b E ) is in the relation, then there is an arrow from of edges (or arcs) a to b
  • • Will generally use relations on a single setConsider our relation R = { ( a,b ) | a divides b }
  • Old way:^12 3 4

1 2 3 4

1 2 (^3 4) Docsity.com

20

Reflexivity

  • Consider a reflexive relation: – One which every element is related to itself ≤
    • Let A = { 1, 2, 3, 4, 5 }

If every node has aloop, a relation is

reflexive

1 2 5 3 (^4) Docsity.com