Definition 6.4.1. Adjacency Matrix.
Let \(A = \{a_1,a_2,\ldots , a_m\}\) and \(B= \{b_1,b_2,\ldots , b_n\}\) be finite sets of cardinality \(m\) and \(n\text{,}\) respectively. Let \(r\) be a relation from \(A\) into \(B\text{.}\) Then \(r\) can be represented by the \(m\times n\) matrix \(R\) defined by
\begin{equation*}
R_{ij}= \left\{
\begin{array}{cc}
1 & \textrm{ if } a_i r b_j \\
0 & \textrm{ otherwise} \\
\end{array}\right.
\end{equation*}
\(R\) is called the adjacency matrix (or the relation matrix) of \(r\text{.}\)
Let \(A = \{2, 5, 6\}\) and let \(r\) be the relation \(\{(2, 2), (2, 5), (5, 6), (6, 6)\}\) on \(A\text{.}\) Since \(r\) is a relation from \(A\) into the same set \(A\) (the \(B\) of the definition), we have \(a_1= 2\text{,}\) \(a_2=5\text{,}\) and \(a_3=6\text{,}\) while \(b_1= 2\text{,}\) \(b_2=5\text{,}\) and \(b_3=6\text{.}\) Next, since
\(2 r 2\text{,}\) we have \(R_{11}= 1\)
\(2 r 5\text{,}\) we have \(R_{12}= 1\)
\(5 r 6\text{,}\) we have \(R_{23}= 1\)
\(6 r 6\text{,}\) we have \(R_{33}= 1\)
All other entries of \(R\) are zero, so
\begin{equation*}
R =\left(
\begin{array}{ccc}
1 & 1 & 0 \\
0 & 0 & 1 \\
0 & 0 & 1 \\
\end{array}
\right)
\end{equation*}