An alternative to the method of Exercise for determining reachability is to use "Boolean multiplication and addition," that is, bitwise and (&) and bitwise or (I ) operations, in carrying out the matrix computations (0 = false, 1 = true).
Rewrite the function in Exercise to find this form of the reachability matrix.