Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Transitive closure
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Smallest transitive relation containing a given binary relation}} {{stack|{{Binary relations}}}} {{About|the transitive closure of a binary relation|the transitive closure of a set|Transitive set#Transitive closure}} In [[mathematics]], the '''transitive closure''' {{math|''R''{{sup|+}}}} of a [[homogeneous binary relation]] {{mvar|R}} on a [[set (mathematics)|set]] {{mvar|X}} is the smallest [[Relation (mathematics)|relation]] on {{mvar|X}} that contains {{mvar|R}} and is [[Transitive relation|transitive]]. For finite sets, "smallest" can be taken in its usual sense, of having the fewest related pairs; for infinite sets {{math|''R''{{sup|+}}}} is the unique [[minimal element|minimal]] transitive [[superset]] of {{math|''R''}}. For example, if {{mvar|X}} is a set of airports and {{mvar|x R y}} means "there is a direct flight from airport {{mvar|x}} to airport {{mvar|y}}" (for {{mvar|x}} and {{mvar|y}} in {{mvar|X}}), then the transitive closure of {{mvar|R}} on {{mvar|X}} is the relation {{math|''R''{{sup|+}}}} such that {{math|''x'' ''R''{{sup|+}} ''y''}} means "it is possible to fly from {{mvar|x}} to {{mvar|y}} in one or more flights". More formally, the transitive closure of a binary relation {{mvar|R}} on a set {{mvar|X}} is the smallest (w.r.t. ⊆) transitive relation {{math|''R''{{sup|+}}}} on {{mvar|X}} such that {{mvar|R}} ⊆ {{math|''R''{{sup|+}}}}; see {{harvtxt|Lidl|Pilz|1998|p=337}}. We have {{math|''R''{{sup|+}}}} = {{mvar|R}} if, and only if, {{mvar|R}} itself is transitive. Conversely, [[transitive reduction]] adduces a minimal relation {{mvar|S}} from a given relation {{mvar|R}} such that they have the same closure, that is, {{math|1=''S''{{sup|+}} = ''R''{{sup|+}}}}; however, many different {{mvar|S}} with this property may exist. Both transitive closure and transitive reduction are also used in the closely related area of [[graph theory]]. == Transitive relations and examples == A relation ''R'' on a set ''X'' is transitive if, for all ''x'', ''y'', ''z'' in ''X'', whenever {{nowrap|''x R y''}} and {{nowrap|''y R z''}} then {{nowrap|''x R z''}}. Examples of transitive relations include the equality relation on any set, the "less than or equal" relation on any linearly ordered set, and the relation "''x'' was born before ''y''" on the set of all people. Symbolically, this can be denoted as: if {{nowrap|''x'' < ''y''}} and {{nowrap|''y'' < ''z''}} then {{nowrap|''x'' < ''z''}}. One example of a non-transitive relation is "city ''x'' can be reached via a direct flight from city ''y''" on the set of all cities. Simply because there is a direct flight from one city to a second city, and a direct flight from the second city to the third, does not imply there is a direct flight from the first city to the third. The transitive closure of this relation is a different relation, namely "there is a sequence of direct flights that begins at city ''x'' and ends at city ''y''". Every relation can be extended in a similar way to a transitive relation. An example of a non-transitive relation with a less meaningful transitive closure is "''x'' is the [[day of the week]] after ''y''". The transitive closure of this relation is "some day ''x'' comes after a day ''y'' on the calendar", which is trivially true for all days of the week ''x'' and ''y'' (and thus equivalent to the [[Cartesian product|Cartesian square]], which is "''x'' and ''y'' are both days of the week"). == Existence and description == For any relation ''R'', the transitive closure of ''R'' always exists. To see this, note that the [[intersection (set theory)|intersection]] of any [[indexed family|family]] of transitive relations is again transitive. Furthermore, [[there exists]] at least one transitive relation containing ''R'', namely the trivial one: ''X'' × ''X''. The transitive closure of ''R'' is then given by the intersection of all transitive relations containing ''R''. For finite sets, we can construct the transitive closure step by step, starting from ''R'' and adding transitive edges. This gives the intuition for a general construction. For any set ''X'', we can prove that transitive closure is given by the following expression :<math>R^{+}=\bigcup_{i = 1}^{\infty} R^i.</math> where <math>R^i</math> is the ''i''-th power of ''R'', defined inductively by :<math>R^1 = R</math> and, for <math>i>0</math>, :<math>R^{i+1} = R \circ R^i</math> where <math>\circ</math> denotes [[composition of relations]]. To show that the above definition of ''R''<sup>+</sup> is the least transitive relation containing ''R'', we show that it contains ''R'', that it is transitive, and that it is the smallest set with both of those characteristics. * <math>R \subseteq R^{+}</math>: <math> R^+</math> contains all of the <math> R^i</math>, so in particular <math> R^+</math> contains <math> R</math>. * <math> R^{+}</math> is transitive: If <math>(s_1, s_2), (s_2, s_3)\in R^+</math>, then <math>(s_1, s_2)\in R^j</math> and <math>(s_2, s_3)\in R^k</math> for some <math>j,k</math> by definition of <math>R^+</math>. Since composition is associative, <math>R^{j+k} = R^j \circ R^k</math>; hence <math>(s_1, s_3)\in R^{j+k} \subseteq R^+</math> by definition of <math>\circ</math> and <math>R^+</math>. * <math>R^{+}</math> is minimal, that is, if <math>T</math> is any transitive relation containing <math>R</math>, then <math>R^{+} \subseteq T</math>: Given any such <math>T</math>, [[mathematical induction|induction]] on <math>i</math> can be used to show <math>R^i\subseteq T</math> for all <math>i</math> as follows: ''Base:'' <math>R^1 = R \subseteq T</math> by assumption. ''Step:'' If <math>R^i\subseteq T</math> holds, and <math>(s_1, s_3)\in R^{i+1} = R \circ R^i</math>, then <math>(s_1, s_2) \in R</math> and <math>(s_2, s_3)\in R^i</math> for some <math>s_2</math>, by definition of <math>\circ</math>. Hence, <math>(s_1, s_2), (s_2, s_3)\in T</math> by assumption and by induction hypothesis. Hence <math>(s_1, s_3)\in T</math> by transitivity of <math>T</math>; this completes the induction. Finally, <math>R^i\subseteq T</math> for all <math>i</math> implies <math>R^{+} \subseteq T</math> by definition of <math>R^{+}</math>. == Properties == The [[Intersection (set theory)|intersection]] of two transitive relations is transitive. The [[union (set theory)|union]] of two transitive relations need not be transitive. To preserve transitivity, one must take the transitive closure. This occurs, for example, when taking the union of two [[equivalence relation]]s or two [[preorder]]s. To obtain a new equivalence relation or preorder one must take the transitive closure (reflexivity and symmetry—in the case of equivalence relations—are automatic). == In graph theory == [[File:Transitive-closure.svg|thumb|right|alt=Transitive closure constructs the output graph from the input graph.|Transitive closure constructs the output graph from the input graph.]] 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 [[Big_O_notation#Orders_of_common_functions|O(1)]] operation one may determine that node ''d'' is reachable from node ''a''. The data structure is typically stored as a Boolean matrix, so if matrix[1][4] = true, then it is the case that node 1 can reach node 4 through one or more hops. The transitive closure of the adjacency relation of a [[directed acyclic graph]] (DAG) is the reachability relation of the DAG and a [[strict partial order]]. [[File:Equivalentie.svg|thumb|A [[cluster graph]], the transitive closure of an undirected graph]] The transitive closure of an [[undirected graph]] produces a [[cluster graph]], a [[disjoint union of graphs|disjoint union]] of [[clique (graph theory)|cliques]]. Constructing the transitive closure is an equivalent formulation of the problem of finding the [[component (graph theory)|components]] of the graph.<ref>{{citation | last1 = McColl | first1 = W. F. | last2 = Noshita | first2 = K. | doi = 10.1016/0166-218X(86)90020-X | issue = 1 | journal = [[Discrete Applied Mathematics]] | mr = 856101 | pages = 67–73 | title = On the number of edges in the transitive closure of a graph | volume = 15 | year = 1986}}</ref> == In logic and computational complexity == The transitive closure of a binary relation cannot, in general, be expressed in [[first-order logic]] (FO). This means that one cannot write a formula using predicate symbols ''R'' and ''T'' that will be satisfied in any model if and only if ''T'' is the transitive closure of ''R''. In [[finite model theory]], first-order logic (FO) extended with a transitive closure operator is usually called '''transitive closure logic''', and abbreviated FO(TC) or just TC. TC is a sub-type of [[fixpoint logic]]s. The fact that FO(TC) is strictly more expressive than FO was discovered by [[Ronald Fagin]] in 1974; the result was then rediscovered by [[Alfred Aho]] and [[Jeffrey Ullman]] in 1979, who proposed to use fixpoint logic as a [[database query language]].<ref>(Libkin 2004:vii)</ref> With more recent concepts of finite model theory, proof that FO(TC) is strictly more expressive than FO follows immediately from the fact that FO(TC) is not [[Gaifman-local]].<ref>(Libkin 2004:49)</ref> In [[computational complexity theory]], the [[complexity class]] [[NL (complexity)|NL]] corresponds precisely to the set of logical sentences expressible in TC. This is because the transitive closure property has a close relationship with the [[NL-complete]] problem [[STCON]] for finding [[directed path]]s in a graph. Similarly, the class [[L (complexity)|L]] is first-order logic with the commutative, transitive closure. When transitive closure is added to [[second-order logic]] instead, we obtain [[PSPACE]]. == In database query languages == {{further|Hierarchical and recursive queries in SQL}} Since the 1980s [[Oracle Database]] has implemented a proprietary [[SQL]] extension <code>CONNECT BY... START WITH</code> that allows the computation of a transitive closure as part of a declarative query. The [[SQL 3]] (1999) standard added a more general <code>WITH RECURSIVE</code> construct also allowing transitive closures to be computed inside the query processor; as of 2011 the latter is implemented in [[IBM Db2]], [[Microsoft SQL Server]], [[Oracle Database|Oracle]], [[PostgreSQL]], and [[MySQL]] (v8.0+). [[SQLite]] released support for this in 2014. [[Datalog]] also implements transitive closure computations.<ref>(Silberschatz et al. 2010:C.3.6)</ref> [[MariaDB]] implements Recursive Common Table Expressions, which can be used to compute transitive closures. This feature was introduced in release 10.2.2 of April 2016.<ref>{{cite web| title=Recursive Common Table Expressions Overview| url=https://mariadb.com/kb/en/recursive-common-table-expressions-overview/| publisher=mariadb.com}}</ref> == Algorithms == Efficient algorithms for computing the transitive closure of the adjacency relation of a graph can be found in {{harvtxt|Nuutila|1995}}. Reducing the problem to multiplications of adjacency matrices achieves the time complexity of [[matrix multiplication]],<ref>{{harvnb|Munro|1971}}, {{harvnb|Fischer|Meyer|1971}}</ref> <math>O(n^{2.3728596})</math>. However, this approach is not practical since both the constant factors and the memory consumption for sparse graphs are high {{harv|Nuutila|1995|pp=22–23|loc=sect.2.3.3}}. The problem can also be solved by the [[Floyd–Warshall algorithm]] in <math>O(n^3)</math>, or by repeated [[breadth-first search]] or [[depth-first search]] starting from each node of the graph. For directed graphs, [[Purdom's algorithm]] solves the problem by first computing its condensation DAG and its transitive closure, then lifting it to the original graph. Its runtime is <math>O(m+\mu n)</math>, where <math>\mu</math> is the number of edges between its [[strongly connected component]]s.<ref name=Purdom>{{cite journal | doi=10.1007/BF01940892 | url= http://digital.library.wisc.edu/1793/57514| first=Paul |last=Purdom Jr. | title=A transitive closure algorithm | journal=[[BIT Numerical Mathematics]] | volume=10 | number=1 | pages=76–94 | date=Mar 1970 }}</ref><ref>{{cite report | url=https://minds.wisconsin.edu/handle/1793/57514 | author=Paul W. Purdom Jr. | title=A transitive closure algorithm | institution=[[University of Wisconsin-Madison]] | type=Computer Sciences Technical Report | volume=33 | date=Jul 1968 }}</ref><ref>{{cite web | url=https://algowiki-project.org/algowiki/en/index.php?title=Purdom%27s_algorithm&oldid=10286 | title="Purdom's algorithm" on AlgoWiki}}</ref><ref>{{cite web | url=https://algowiki-project.org/algowiki/en/index.php?title=Transitive_closure_of_a_directed_graph&oldid=1475 | title="Transitive closure of a directed graph" on AlgoWiki}}</ref> More recent research has explored efficient ways of computing transitive closure on distributed systems based on the [[MapReduce]] paradigm.<ref>(Afrati et al. 2011)</ref> == See also == * [[Ancestral relation]] * [[Deductive closure]] * [[Reflexive closure]] * [[Symmetric closure]] * [[Transitive reduction]] (a smallest relation having the transitive closure of ''R'' as its transitive closure) == References == {{Reflist}} * [[Foto Afrati|Foto N. Afrati]], Vinayak Borkar, [[Michael J. Carey (computer scientist)|Michael Carey]], Neoklis Polyzotis, [[Jeffrey Ullman|Jeffrey D. Ullman]], [https://web.archive.org/web/20140810063150/http://www.edbt.org/Proceedings/2011-Uppsala/papers/edbt/a1-afrati.pdf Map-Reduce Extensions and Recursive Queries], EDBT 2011, March 22–24, 2011, Uppsala, Sweden, {{isbn|978-1-4503-0528-0}} * {{Cite book | last1 = Aho | first1 = A. V. | author1-link = Alfred Aho | last2 = Ullman | first2 = J. D. | author2-link = Jeffrey Ullman | doi = 10.1145/567752.567763 | chapter = Universality of data retrieval languages | title = Proceedings of the 6th ACM SIGACT-SIGPLAN Symposium on Principles of programming languages - POPL '79 | pages = 110–119 | year = 1979 }} * {{Cite book | last1 = Benedikt | first1 = M. | last2 = Senellart | first2 = P. | doi = 10.1007/978-1-4614-1168-0_10 | chapter = Databases | title = Computer Science. The Hardware, Software and Heart of It| pages = 169–229| year = 2011 | isbn = 978-1-4614-1167-3 | editor1-last = Blum| editor1-first = Edward K.| editor2-last = Aho| editor2-first = Alfred V. }} * {{cite book|author1=Heinz-Dieter Ebbinghaus|author2=Jörg Flum|title=Finite Model Theory|url=https://archive.org/details/finitemodeltheor0000ebbi|url-access=registration|year=1999|publisher=Springer|isbn=978-3-540-28787-2|edition=2nd|pages=[https://archive.org/details/finitemodeltheor0000ebbi/page/123 123]–124, 151–161, 220–235}} * {{cite conference | doi=10.1109/SWAT.1971.4 | contribution-url=http://mercury.pr.erau.edu/~siewerts/cs332/documents/Papers/Transitive-Closure/Transitive-Closure-with-Boolean-Matrices.pdf | first1=M.J. |last1=Fischer |first2=A.R. |last2=Meyer | contribution=Boolean matrix multiplication and transitive closure | editor=Raymond E. Miller and John E. Hopcroft | title=Proc. 12th Ann. Symp. on Switching and Automata Theory (SWAT) | publisher=IEEE Computer Society | pages=129–131 | date=Oct 1971 }} * {{cite book|author1=Erich Grädel|author2=Phokion G. Kolaitis|author3=Leonid Libkin |author4=Maarten Marx |author5=Joel Spencer |author6=Moshe Y. Vardi |author7=Yde Venema |author8=Scott Weinstein|title=Finite Model Theory and Its Applications|year=2007|publisher=Springer|isbn=978-3-540-68804-4|pages=151–152}} * Keller, U., 2004, ''[http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.127.8266 Some Remarks on the Definability of Transitive Closure in First-order Logic and Datalog]'' (unpublished manuscript)* {{citation|first=Leonid|last=Libkin|author-link=Leonid Libkin|title=Elements of Finite Model Theory|year=2004|publisher=Springer|isbn=978-3-540-21202-7|url-access=registration|url=https://archive.org/details/elementsoffinite00libk}} * {{citation|last1=Lidl|first1= R.|last2=Pilz|first2=G.|year=1998|title=''Applied abstract algebra''|edition=2nd|series= [[Undergraduate Texts in Mathematics]]|publisher= Springer|isbn=0-387-98290-6}} * {{cite journal|last=Munro| first=Ian | doi=10.1016/0020-0190(71)90006-8 | url= | title=Efficient determination of the transitive closure of a directed graph | journal=Information Processing Letters | volume=1 | number=2 | pages=56–58 | date=Jan 1971 }} * {{Cite book|last=Nuutila|first=Esko|url=http://worldcat.org/oclc/912471702|title=Efficient transitive closure computation in large digraphs|date=1995|publisher=Finnish Academy of Technology|isbn=951-666-451-2|oclc=912471702}} * {{cite book|author1=Abraham Silberschatz|author2=Henry Korth|author3=S. Sudarshan|title=Database System Concepts|year=2010|edition=6th|publisher=McGraw-Hill|isbn=978-0-07-352332-3|title-link=Database System Concepts}} [http://codex.cs.yale.edu/avi/db-book/db6/appendices-dir/c.pdf Appendix C] (online only) == External links == * "[http://www.cs.sunysb.edu/~algorith/files/transitive-closure.shtml Transitive closure and reduction]", The Stony Brook Algorithm Repository, Steven Skiena. {{Order theory}} [[Category:Binary relations]] [[Category:Closure operators]] [[Category:Graph algorithms]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:Citation
(
edit
)
Template:Cite book
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite report
(
edit
)
Template:Cite web
(
edit
)
Template:Further
(
edit
)
Template:Harv
(
edit
)
Template:Harvnb
(
edit
)
Template:Harvtxt
(
edit
)
Template:Isbn
(
edit
)
Template:Math
(
edit
)
Template:Mvar
(
edit
)
Template:Nowrap
(
edit
)
Template:Order theory
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Stack
(
edit
)