14.8 KB · commit a9602da
In this section, and in the remainder of this chapter, all relations we study will be binary relations. Because of this, in this section and in the rest of this chapter, the word relation will always refer to a binary relation. There are many ways to represent a relation between finite sets. As we have seen in Section 9.1, one way is to list its ordered pairs. Another way to represent a relation is to use a table, as we did in Example 3 in Section 9.1. In this section we will discuss two alternative methods for representing relations. One method uses zero–one matrices. The other method uses pictorial representations called directed graphs, which we will discuss later in this section.
Generally, matrices are appropriate for the representation of relations in computer programs. On the other hand, people often find the representation of relations using directed graphs useful for understanding the properties of these relations.
A relation between finite sets can be represented using a zero–one matrix. Suppose that R is a relation from A={a1,a2,…,am} to B={b1,b2,…,bn}. (Here the elements of the sets A and B have been listed in a particular, but arbitrary, order. Furthermore, when A=B we use the same ordering for A and B.) The relation R can be represented by the matrix MR=[mij], where
mij={10if (ai,bj)∈R,if (ai,bj)∈/R.
In other words, the zero–one matrix representing R has a 1 as its (i,j) entry when ai is related to bj, and a 0 in this position if ai is not related to bj. (Such a representation depends on the orderings used for A and B.)
The use of matrices to represent relations is illustrated in Examples 1–6.
Suppose that A={1,2,3} and B={1,2}. Let R be the relation from A to B containing (a,b) if a∈A, b∈B, and a>b. What is the matrix representing R if a1=1, a2=2, and a3=3, and b1=1 and b2=2?
Solution: Because R={(2,1),(3,1),(3,2)}, the matrix for R is
MR=011001.
The 1s in MR show that the pairs (2,1), (3,1), and (3,2) belong to R. The 0s show that no other pairs belong to R. ◀
Let A={a1,a2,a3} and B={b1,b2,b3,b4,b5}. Which ordered pairs are in the relation R represented by the matrix
MR=011100011010001?
Solution: Because R consists of those ordered pairs (ai,bj) with mij=1, it follows that
R={(a1,b2),(a2,b1),(a2,b3),(a2,b4),(a3,b1),(a3,b3),(a3,b5)}.◀
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties. Recall that a relation R on A is reflexive if (a,a)∈R whenever a∈A. Thus, R is reflexive if and only if (ai,ai)∈R for i=1,2,…,n. Hence, R is reflexive if and only if mii=1, for i=1,2,…,n. In other words, R is reflexive if all the elements on the main diagonal of MR are equal to 1, as shown in Figure 1. Note that the elements off the main diagonal can be either 0 or 1.
Figure 1 — The Zero–One Matrix for a Reflexive Relation. (Off Diagonal Elements Can Be 0 or 1.)
The relation R is symmetric if (a,b)∈R implies that (b,a)∈R. Consequently, the relation R on the set A={a1,a2,…,an} is symmetric if and only if (aj,ai)∈R whenever (ai,aj)∈R. In terms of the entries of MR, R is symmetric if and only if mji=1 whenever mij=1. This also means mji=0 whenever mij=0. Consequently, R is symmetric if and only if mij=mji, for all pairs of integers i and j with i=1,2,…,n and j=1,2,…,n. Recalling the definition of the transpose of a matrix from Section 2.6, we see that R is symmetric if and only if
MR=(MR)t,
that is, if MR is a symmetric matrix. The form of the matrix for a symmetric relation is illustrated in Figure 2(a).
The relation R is antisymmetric if and only if (a,b)∈R and (b,a)∈R imply that a=b. Consequently, the matrix of an antisymmetric relation has the property that if mij=1 with i=j, then mji=0. Or, in other words, either mij=0 or mji=0 when i=j. The form of the matrix for an antisymmetric relation is illustrated in Figure 2(b).
Figure 2 — The Zero–One Matrices for Symmetric and Antisymmetric Relations.
Suppose that the relation R on a set is represented by the matrix
MR=110111011.
Is R reflexive, symmetric, and/or antisymmetric?
Solution: Because all the diagonal elements of this matrix are equal to 1, R is reflexive. Moreover, because MR is symmetric, it follows that R is symmetric. It is also easy to see that R is not antisymmetric. ◀
The Boolean operations join and meet (discussed in Section 2.6) can be used to find the matrices representing the union and the intersection of two relations. Suppose that R1 and R2 are relations on a set A represented by the matrices MR1 and MR2, respectively. The matrix
representing the union of these relations has a 1 in the positions where either MR1 or MR2 has a 1. The matrix representing the intersection of these relations has a 1 in the positions where both MR1 and MR2 have a 1. Thus, the matrices representing the union and intersection of these relations are
MR1∪R2=MR1∨MR2andMR1∩R2=MR1∧MR2.
Suppose that the relations R1 and R2 on a set A are represented by the matrices
MR1=110001100andMR2=101010110.
What are the matrices representing R1∪R2 and R1∩R2?
Solution: The matrices of these relations are
MR1∪R2=MR1∨MR2=111011110,
MR1∩R2=MR1∧MR2=100000100.◀
We now turn our attention to determining the matrix for the composite of relations. This matrix can be found using the Boolean product of the matrices (discussed in Section 2.6) for these relations. In particular, suppose that R is a relation from A to B and S is a relation from B to C. Suppose that A, B, and C have m, n, and p elements, respectively. Let the zero–one matrices for S∘R, R, and S be MS∘R=[tij], MR=[rij], and MS=[sij], respectively (these matrices have sizes m×p, m×n, and n×p, respectively). The ordered pair (ai,cj) belongs to S∘R if and only if there is an element bk such that (ai,bk) belongs to R and (bk,cj) belongs to S. It follows that tij=1 if and only if rik=skj=1 for some k. From the definition of the Boolean product, this means that
MS∘R=MR⊙MS.
Find the matrix representing the relations S∘R, where the matrices representing R and S are
MR=110010100andMS=001100011.
Solution: The matrix for S∘R is
MS∘R=MR⊙MS=100110110.◀
The matrix representing the composite of two relations can be used to find the matrix for MRn. In particular,
MRn=MR[n],
from the definition of Boolean powers. Exercise 35 asks for a proof of this formula.
Find the matrix representing the relation R2, where the matrix representing R is
MR=001110010.
Solution: The matrix for R2 is
MR2=MR[2]=010111110.◀
We have shown that a relation can be represented by listing all of its ordered pairs or by using a zero–one matrix. There is another important way of representing a relation using a pictorial representation. Each element of the set is represented by a point, and each ordered pair is represented using an arc with its direction indicated by an arrow. We use such pictorial representations when we think of relations on a finite set as directed graphs, or digraphs.
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.
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. ◀
The relation R on a set A is represented by the directed graph that has the elements of A as its vertices and the ordered pairs (a,b), where (a,b)∈R, as edges. This assignment sets up a one-to-one correspondence between the relations on a set A and the directed graphs with A as their set of vertices. Thus, every statement about relations corresponds to a statement about directed graphs, and vice versa. Directed graphs give a visual display of information about relations. As such, they are often used to study relations and their properties. (Note that relations from a set A to a set B can be represented by a directed graph where there is a vertex for each element of A and a vertex for each element of B, as shown in Section 9.1. However, when A=B, such representation provides much less insight than the digraph representations described here.) The use of directed graphs to represent relations on a set is illustrated in Examples 8–10.
Figure 3 — A Directed Graph.
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. ◀
What are the ordered pairs in the relation R represented by the directed graph shown in Figure 5?
Solution: The ordered pairs (x,y) in the relation are
R={(1,3),(1,4),(2,1),(2,2),(2,3),(3,1),(3,3),(4,1),(4,3)}.
Each of these pairs corresponds to an edge of the directed graph, with (2,2) and (3,3) corresponding to loops. ◀
The directed graph representing a relation can be used to determine whether the relation has various properties. For instance, a relation is reflexive if and only if there is a loop at every vertex of the directed graph, so that every ordered pair of the form (x,x) occurs in the relation. A relation is symmetric if and only if for every edge between distinct vertices in its digraph there is an edge in the opposite direction, so that (y,x) is in the relation whenever (x,y) is in the relation. Similarly, a relation is antisymmetric if and only if there are never two edges in opposite directions between distinct vertices. Finally, a relation is transitive if and only if whenever there is an edge from a vertex x to a vertex y and an edge from a vertex y to a vertex z, there is an edge from x to z (completing a triangle where each side is a directed edge with the correct direction).
Determine whether the relations for the directed graphs shown in Figure 6 are reflexive, symmetric, antisymmetric, and/or transitive.
Solution: Because there are loops at every vertex of the directed graph of R, it is reflexive. R is neither symmetric nor antisymmetric because there is an edge from a to b but not one from b to a, but there are edges in both directions connecting b and c. Finally, R is not transitive because there is an edge from a to b and an edge from b to c, but no edge from a to c.
Figure 4 — The Directed Graph of the Relation R.
Figure 5 — The Directed Graph of the Relation R.
Figure 6 — The Directed Graphs of the Relations R and S.
Because loops are not present at all the vertices of the directed graph of S, this relation is not reflexive. It is symmetric and not antisymmetric, because every edge between distinct vertices is accompanied by an edge in the opposite direction. It is also not hard to see from the directed graph that S is not transitive, because (c,a) and (a,b) belong to S, but (c,b) does not belong to S. ◀