Nested set model: Difference between revisions

Content deleted Content added
m linking
Undid revision 882186438 by Akhil Surapuram (talk) misguided or possibly vandalistic
Line 16:
 
==The technique==
The nested set model is to number the nodes according to a [https://www.techiedelight.com/arrival-departure-time-vertices-dfs/[tree traversal (DFS arrival and departure of vertices)] ], which visits each node twice, assigning numbers in the order of visiting, and at both visits. This leaves two numbers for each node, which are stored as two attributes. Querying becomes inexpensive: hierarchy membership can be tested by comparing these numbers. Updating requires renumbering and is therefore expensive. Refinements that use [[rational number]]s instead of integers can avoid renumbering, and so are faster to update, although much more complicated.<ref>{{cite arXiv |eprint=0806.3115 | first= Daniel|last = Hazel | title = Using rational numbers to key nested sets}}</ref>
 
==Example==
In a clothing store catalog, clothing may be categorisedcategorized according to the hierarchy given on the left:
 
[[File:NestedSetModel.svg|thumb|400px|A hierarchy: types of clothing]]