Binary Relations
Binary Relations
Properties
b. symmetric: if for every x and y in X, whenever xRy holds, then yRx holds.
c. transitive: if for every x, y, and z in X, whenever xRy holds and yRz holds, then xRz holds.
Graphical Representation
Suppose that X = {A, B, C, D} and that R = {(A, B), (B, D), (C, C), (D, B)}. We can represent the binary
relation R as a set, as a graph or as a Boolean matrix. Graphically, we have
A B C D
A 0 1 0 0
B 0 0 0 1
C 0 0 1 0
D 0 1 0 0
What would a Boolean matrix look like if it represented a reflexive binary relation, a symmetric binary
relation, a transitive binary relation, any combination of the above?
Reflexive Relation
A B C D
A - 1 - -
B - - - 1
C - - 1 -
D - 1 - -
Symmetric Relation
A B C D
A - 1 - -
B - - - 1
C - - 1 -
D - 1 - -
Transitive Relation
A B C D
A - 1 - -
B - - - 1
C - - 1 -
D - 1 - -
Let R be a relation from X to Y, and S be a relation from Y to Z. Then a relation written as R o S is called
a composite relation of R and S where
Note: Relational composition can be realized as matrix multiplication. For example, let MR and MS
represent the binary relations R and S, respectively. Then R o S can be computed via MR MS.
e.g.
xPy
means that x is the parent of y. From this binary relation we can compute: child, grandparent, sibling
child: x C y = y P x
grandparent: x GP y = x P z z P y or GP = P o P
sibling: x S y = z P x z P y
x S y = x P-1 z z P y or S = P-1 o P
Suppose that
P = {(a, b), (a, c), (b, d), (b, e), (c, f), (f, g)}
Compute the children, grandparents, siblings, aunt/uncle, and cousins for this parent relation.
Closure
Reflexive Closure:
Symmetric Closure:
Transitive Closure:
R^ = R R2 R3 ……
Let M represent the binary relation R, R^ represents the transitive closure of R, and M^ represent the
transitive closure. Then representing the transitive closure via Boolean matrices, we have
M^ = M + M2 + M3 + …
e.g.
Suppose R = {(1,2), (1,5), (2,3), (3,5), (4,3), (5,4)}. Compute the reflexive closure, symmetric
closure, and transitive closure.
Reflexive Closure
1 2 3 4 5
1 - 1 - - 1
2 - - 1 - -
3 - - - - 1
4 - - 1 - -
5 - - - 1 -
Symmetric Closure
1 2 3 4 5
1 - 1 - - 1
2 - - 1 - -
3 - - - - 1
4 - - 1 - -
5 - - - 1 -
Transitive Closure
1 2 3 4 5 1 2 3 4 5
1 - 1 - - 1 - - - - -
2 - - 1 - - - - - - -
3 - - - - 1 - - - - -
4 - - 1 - - - - - - -
5 - - - 1 - - - - - -
Warshall's Algorithm:
1 2 3 4 5
1 - 1 - - 1
2 - - 1 - -
3 - - - - 1
4 - - 1 - -
5 - - - 1 -
A B C D
A 1 1 - -
B - 1 - 1
C - - 1 -
D - 1 - 1
A B C D
A - 1 - -
B 1 - - 1
C - - 1 -
D - 1 - -
A B C D
A 1 1 - -
B 1 1 - 1
C - - 1 -
D - 1 - 1
Return
Reflexive Closure
1 2 3 4 5
1 1 1 - - 1
2 - 1 1 - -
3 - - 1 - 1
4 - - 1 1 -
5 - - - 1 1
Symmetric Closure
1 2 3 4 5
1 - 1 - - 1
2 1 - 1 - -
3 - 1 - 1 1
4 - - 1 - 1
5 1 - 1 1 -
Transitive Closure
1 2 3 4 5 1 2 3 4 5
1 - 1 - - 1 - - 1 1 -
2 - - 1 - - - - - - 1
3 - - - - 1 - - - 1 -
4 - - 1 - - - - - - 1
5 - - - 1 - - - 1 - -
Warshall's Algorithm
1 2 3 4 5
1 - 1 1 1 1
2 - - 1 1 1
3 - - 1 1 1
4 - - 1 1 1
5 - - 1 1 1