A ''tree'' is an acyclic directed-[graph] [data structure] where one node (the root) has no predecessor, and all other nodes have exactly one predecessor. Trees can be used, e.g., for representing the result in syntax parsing. Every [XML] document has a tree structure. [Tcllib] contains a tree data structure. Documentation for it can be found at * http://tcllib.sourceforge.net/doc/tree.html (ver 1.3) * http://tcllib.sourceforge.net/doc/struct_tree.html (ver 2.0) * http://docs.activestate.com/activetcl/8.5/tcllib/struct/struct_tree1.html * http://docs.activestate.com/activetcl/8.5/tcllib/struct/struct_tree.html This module of the [tcllib] data [struct]ures collection provides the data structure portion of a tree structure. The tcllib Tree would be more useful if nodes could be arbitrary objects (specifically, if they could be [incr Tcl] objects). To that end, I made some mods which [string map] {:: @} in the creation of [namespace] data arrays. Worth adding to the mainline? [CMCc] [AMG]: A tree is sometimes called a DAG because it is a directed acyclic graph. I find this to be a useful mnemonic. [NEM]: Well, all trees are DAGs, but not all DAGs are trees. [AMG]: Yes, quite right; see the other tree properties listed in the first line of this page. ---- [LV] In the following text, I notice a number of cases where GUI widget sets have some sort of '''tree''' widget. In each of these cases, is the data structure intermingled with the data representation? Seems a shame that someone doesn't just build a graphically viewable widget that depends on a data structure that is separate. That way, someone could do work with one piece of code, and then, in other pieces, display that data. Seems like a natural method of developing and maintaining code.... ---- Also, [BWidget] has a [Tree] widget. (See [Tree nodes in motion] - [starDom] - [LemonTree]). ---- For a lightweight approach, see [Trees as nested lists]. ---- Related topics: * [Containers] tree container command * [ODIE] environment which has tools for data tree maintenance * [RBTree] red-black tree data type * [Tree Objects] discussed by [Clif Flynt] * [Various useful Tcl packages (Rempel)] includes some tree operation packages * graphical representation of tree data * a "tree widget", often for filesystem data, which appears in particular the [TkTreeCtrl] widget, tree widgets from the [Hipp miscellaneous widgets], [mtree widget], as well as the [BWidget], [BLT], [Tix], [ClassyTk], [incr widgets]' hierarchy widget, [mkWidgets], [PRS Open Source Software], [Zinc] packages, and the pure-[Python] TreeWidget [http://oomadness.tuxfamily.org/p-treewidget.php] for [Tkinter]. Among these, treectrl is complex for beginners, while the more accessible BWidget one ''does'' have edit capabilities. * [Tk Tree Widget in C++], [tkgcv], [hierarchy], [Tree Table], born2net's [Iwidgets] version of Hipp's tree widget, Brighton's Iwidgets tree widget, Mutlu's Iwidgets version of a tree widget, Pryce's itk widget base class are some older examples of tree widget implementations * Also check out [tktree] for a tcl/tk tree widget * [GRIDPLUS] has a basic scrollable tree widget * [What's wrong with the tree widgets?] * Martyn, Ruediger, and Alexander analyze different tree widgets and their use with 8.4, here [http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/ec0d418c556c8091/]. <> Arts and Crafts of Tcl-Tk Programming | Command | tcllib | struct | Data Structure