For example, if X is a set of airports and xRy means "there is a direct flight from airport x to airport y", then the transitive closure of R is the relation "it is possible to fly from x to y in one or more flights." Or, if X is the set of humans (alive or dead) and R is the relation 'parent of', then the transitive closure of R is the relation "x is an ancestor of y".
We can describe the transitive closure of R in more concrete terms as follows. Define a relation T on X by saying xTy iff there exists a finite sequence of elements (xi) such that x = x0 and
Let A be any set of elements.
Supposition: GA transitive relationship RAGA TAGA. So, (a,b)GA(a,b)TA. So, that particular (a,b)RA.
Now, by definition of T, we know that n (a,b)RnA. Then, i, in eiA. So, there is a path from a to b like this: aRAe1RA...RAe(n-1)RAb.
But, by transitivity of GA on RA, i, in (a,ei)GA, so (a,e(n-1))GA (e(n-1),b)GA, so by transitivity of GA, we get (a,b)GA. A Contradiction of (a,b)GA.
Therefore, (a,b)AA, (a,b)TA (a,b)GA. This means that TG, for any transitive G containing R. So, T is the smallest transitive relationship containing R.
If R is transitive, then R = T.
The transitive closure of a directed acyclic graph or DAG is the reachability relation of the DAG and a strict partial order.
In computer science the concept of transitive closure can be thought of as constructing a data structure that makes it possible to answer reachability questions. That is, can one get from node a to node d in one or more hops? A binary relation tells you only that node a is connected to node b, and that node b is connected to node c, etc. After the transitive closure is constructed, as depicted in the following figure, in an O(1) operation one may determine that node d is reachable from node a. The data structure is typically stored as a matrix, so if matrix[1][4] = 1, then it is the case that node 1 can reach node 4 through one or more hops.
In computational complexity theory, the complexity class NL corresponds precisely to the set of logical sentences expressible using first-order logic together with transitive closure. This is because the transitive closure property has a close relationship with the NL-complete problem STCON for finding directed paths in a graph. Similarly, the class L is first-order logic with the commutative, transitive closure. When transitive closure is added to second-order logic instead, we obtain PSPACE.
Efficient algorithms for computing the transitive closure of a graph can be found here The simplest technique is probably the Floyd-Warshall algorithm.