$\begin{bmatrix}
0 & 1 & 1 & 0 & 0 & 1 \\
1 & 0 & 1 & 1 & 0 & 0 \\
0 & 1 & 0 & 1 & 1 & 1 \\
1 & 1 & 1 & 0 & 1 & 0 \\
0 & 1 & 0 & 1 & 0 & 1 \\
1 & 1 & 0 & 1 & 1 & 0 \\
\end{bmatrix}$
If above is a binary relation in it's matrix representation.
Then the following is the $O(V^3)$ Warshall's Algorithm to find the Transitive closure of the underlying graph or binary relation.
for(int via = 0; via < V; via++) {
for(int start = 0; start < V; start++) {
for(int end = 0; end < V; end++) {
matrix[start][end] = matrix[start][end] | ( matrix[start][via] & matrix[via][end] );
}
}
}