Alternate method of finding the transitive closure of graph or relation.
The union of
(u,v) is an edge in
The same definition holds for a relation R.
The relation
all the pairs from R. In other words, any relation that contains all the pairs from R and is transitive must include all
the pairs in
Graph each power of G (up to
- Take adjacency matrix A for graph G
- compute A^k by matrix multiplication
- A^k is adjacency matrix for G^k, thus G contains walk of lenght k iff entry in A^k = 1
There is another way to find the transitive closure of a graph or relation that does not require computing the powers directly. The process repeatedly looks for three elements x, y, z, such that (x,y) and (y,z) are pairs in the relation but (x,z) is not in the relation. If there is such a triplet of elements, then the pair (x,z) is added to the relation. The process ends when there is no such triplet of elements.
Repeat the following step until no pair is added to R.
If there are three elements x,y,z ∈ A such that (x,y) ∈ R, (y,z) ∈ R and (x,z) ∉ R, then add (x,z) to R