Transitive closure

created by linux8086
(idea) by linux8086 (8.2 y) (print)   (I like it!) Mon Apr 24 2000 at 3:20:44
The closure of a relation to make it transitive. See Warshall's algorithm.
(idea) by Evandar (2.1 y) (print)   (I like it!) Fri Jan 05 2001 at 3:25:45
Confusingly enough, "transitive closure of a set" means something completely different to "transitive closure of a relation".

Recall that a set A is said to be transitive if whenever x is in A and y is in x then y is in A. To put that another way, every member is also a subset.

If X is any set, the transitive closure of X is the smallest set Y such that Y is transitive and contains X. "Smallest" in this context means that whenever Z is transitive and contains X, then Z contains Y.

It can be shown that every set has a transitive closure; this is an application of the recursion theorem.

(idea) by Recluse (4.3 y) (print)   (I like it!) Sat Apr 27 2002 at 22:29:41

Stepping aside from set theory for a moment - the transitive closure of a graph is another interesting problem/property. For a directed graph G = (V, E), the transitive closure of G is the graph (call it G') (V, E') such that an edge e is in E' if and only if there is a directed path from ev1 to ev2. That is, the edge set of G' is all pairs of vertices in G where there is a path between the two vertices.

I don't suppose that was very enlightening, was it? Alright then, express the edge set of G as the relation Edge(A, B), where A and B are the endpoints of an edge. In datalog, one program that would find the relation describing all edges in the transitive closure of G would be:

  • Closure(x,y)<--Edge(x,y)
  • Closure(x,y)<--Closure(x,z), Edge(z,y)

I will state here, without backing it up (another node for another day, if it doesn't exist), that to find the transitive closure of a graph, the toolset you use needs to have some sort of iterative or recursive tool. This is why transitive closure can be found simply in datalog, but cannot be expressed at all in simple relational algebras (any of the first few described in relational algebra, for example). To find the transitive closure of a graph using relational algebra (using the same sort of relation as described above for datalog), you would need to add a while or fixpoint operator.

Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.