Efficient algorithm to compute the transitive closure of a relation.