Loading [MathJax]/jax/output/HTML-CSS/jax.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

6.4: Matrices of Relations

( \newcommand{\kernel}{\mathrm{null}\,}\)

We have discussed two of the many possible ways of representing a relation, namely as a digraph or as a set of ordered pairs. In this section we will discuss the representation of relations by matrices.

Representing a Relation with a Matrix

Definition 6.4.1: Adjacency Matrix

Let A={a1,a2,,am} and B={b1,b2,,bn} be finite sets of cardinality m and n, respectively. Let r be a relation from A into B. Then r can be represented by the m×n matrix R defined by

Rij={1 if airbj0 otherwise

R is called the adjacency matrix (or the relation matrix) of r.

Example 6.4.1: A Simple Example

Let A={2,5,6} and let r be the relation {(2,2),(2,5),(5,6),(6,6)} on A. Since r is a relation from A into the same set A (the B of the definition), we have a1=2, a2=5, and a3=6, while b1=2, b2=5, and b3=6. Next, since

  • 2r2, we have R11=1
  • 2r5, we have R12=1
  • 5r6, we have R23=1
  • 6r6, we have R33=1

All other entries of R are zero, so

R=(110001001)

Composition as Matrix Multiplication

From the definition of r and of composition, we note that

r2={(2,2),(2,5),(2,6),(5,6),(6,6)}

The adjacency matrix of r2 is

R2=(111001001).

We do not write R2 only for notational purposes. In fact, R2 can be obtained from the matrix product RR; however, we must use a slightly different form of arithmetic.

Definition 6.4.2: Boolean Arithmetic

Boolean arithmetic is the arithmetic defined on {0,1} using Boolean addition and Boolean multiplication, defined by

Table 6.4.1

0+0=0 0+1=1+0=1 1+1=1
00=0 01=10=0 11=1

Notice that from Chapter 3, this is the “arithmetic of logic,” where + replaces “or” and replaces “and.”

Example 6.4.2: Composition by Multiplication

Suppose that R=(0100101001010010) and S=(0111001100010000). Then using Boolean arithmetic, RS=(0011011100110001) and SR=(1111011100100000).

Theorem 6.4.1: Composition is Matrix Multiplication

Let A1, A2, and A3 be finite sets where r1 is a relation from A1 into A2 and r2 is a relation from A2 into A3. If R1 and R2 are the adjacency matrices of r1 and r2, respectively, then the product R1R2 using Boolean arithmetic is the adjacency matrix of the composition r1r2.

Remark: A convenient help in constructing the adjacency matrix of a relation from a set A into a set B is to write the elements from A in a column preceding the first column of the adjacency matrix, and the elements of B in a row above the first row. Initially, R in Example 6.4.1 would be

256256()

To fill in the matrix, Rij is 1 if and only if (ai,bj)r. So that, since the pair (2,5)r, the entry of R corresponding to the row labeled 2 and the column labeled 5 in the matrix is a 1.

Example 6.4.3: Relations and Information

This final example gives an insight into how relational data base programs can systematically answer questions pertaining to large masses of information. Matrices R (on the left) and S (on the right) define the relations r and s where arb if software a can be run with operating system b, and bsc if operating system b can run on computer c.

OS1OS2OS3OS4P1P2P3P4(1010110000010011)C1C2C3OS1OS2OS3OS4(110010001011)

Although the relation between the software and computers is not implicit from the data given, we can easily compute this information. The matrix of rs is RS, which is

C1C2C3P1P2P3P4(111110011011)

This matrix tells us at a glance which software will run on the computers listed. In this case, all software will run on all computers with the exception of program P2, which will not run on the computer C3, and programs P3 and P4, which will not run on the computer C1.

Exercises

Exercise 6.4.1

Let A1={1,2,3,4}, A2={4,5,6}, and A3={6,7,8}. Let r1 be the relation from A1 into A2 defined by r1={(x,y)yx=2}, and let r2 be the relation from A2 into A3 defined by r2={(x,y)yx=1}.

  1. Determine the adjacency matrices of r1 and r2.
  2. Use the definition of composition to find r1r2.
  3. Verify the result in part b by finding the product of the adjacency matrices of r1 and r2.
Answer
  1. 4561234(000100010001) and 678456(000100010)
  2. r1r2={(3,6),(4,7)}
  3. 6781234(000000100010)

Exercise 6.4.2

  1. Determine the adjacency matrix of each relation given via the digraphs in Exercise 6.3.3 of Section 6.3.
  2. Using the matrices found in part (a) above, find r2 of each relation in Exercise 6.3.3 of Section 6.3.
  3. Find the digraph of r2 directly from the given digraph and compare your results with those of part (b).

Exercise 6.4.3

Suppose that the matrices in Example 6.4.2 are relations on {1,2,3,4}. What relations do R and S describe?

Answer

Table 6.4.2

R : xry if and only if |xy|=1
S : xsy if and only if x is less than y.

Exercise 6.4.4

Let D be the set of weekdays, Monday through Friday, let W be a set of employees {1,2,3} of a tutoring center, and let V be a set of computer languages for which tutoring is offered, {A(PL),B(asic),C(++),J(ava),L(isp),P(ython)}. We define s (schedule) from D into W by dsw if w is scheduled to work on day d. We also define r from W into V by wrl if w can tutor students in language l. If s and r are defined by matrices

S=123MTWRF(101011101010110) and R=ABCJLP123(011001110101010011)

  1. compute SR using Boolean arithmetic and give an interpretation of the relation it defines, and
  2. compute SR using regular arithmetic and give an interpretation of what the result describes.

Exercise 6.4.5

How many different reflexive, symmetric relations are there on a set with three elements?

Hint

Consider the possible matrices.

Answer

The diagonal entries of the matrix for such a relation must be 1. When the three entries above the diagonal are determined, the entries below are also determined. Therefore, there are 23 fitting the description.

Exercise 6.4.6

Let A={a,b,c,d}. Let r be the relation on A with adjacency matrix abcdabcd(1000010011100101)

  1. Explain why r is a partial ordering on A.
  2. Draw its Hasse diagram.

Exercise 6.4.7

Define relations p and q on {1,2,3,4} by p={(a,b)|ab|=1} and q={(a,b)ab is even}.

  1. Represent p and q as both graphs and matrices.
  2. Determine pq, p2, and q2; and represent them clearly in any way.
Answer
  1. 12341234(0100101001010010) and 12341234(1010010110100101)
  2. PQ=12341234(0100101001010010) P2= 12341234(0100101001010010)=Q2

Exercise 6.4.8

  1. Prove that if r is a transitive relation on a set A, then r2r.
  2. Find an example of a transitive relation for which r2r.

Exercise 6.4.9

We define on the set of all n×n relation matrices by the rule that if R and S are any two n×n relation matrices, RS if and only if RijSij for all 1i,jn.

  1. Prove that is a partial ordering on all n×n relation matrices.
  2. Prove that RSR2S2 , but the converse is not true.
  3. If R and S are matrices of equivalence relations and RS, how are the equivalence classes defined by R related to the equivalence classes defined by S?
Answer
  1. Reflexive: Rij=Rij for all i, j, therefore RijRij
    Antisymmetric: Assume RijSij and SijRij for all 1i, jn. Therefore, Rij=Sij for all 1i, jn and so R=S
    Transitive: Assume R,S, and T are matrices where RijSij and SijTij, for all 1i, jn. Then RijTij for all 1i, jn, and so RT.
  2. (R2)ij=Ri1R1j+Ri2R2j++RinRnjSi1S1j+Si2S2j++SinSnj=(S2)ijR2S2
    To verify that the converse is not true we need only one example. For n=2, let R12=1 and all other entries equal 0, and let S be the zero matrix. Since R2 and S2 are both the zero matrix, R2S2, but since R12>S12, RS is false.
  3. The matrices are defined on the same set A={a1,a2,,an}. Let c(ai), i=1,2,,n be the equivalence classes defined by R and let d(ai) be those defined by S. Claim: c(ai)d(ai).
    ajc(ai)airajRij=1Sij=1aisajajd(ai)

This page titled 6.4: Matrices of Relations is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Al Doerr & Ken Levasseur via source content that was edited to the style and standards of the LibreTexts platform.

Support Center

How can we help?