Version 29 of Tree

Updated 2016-01-03 08:15:05 by pooryorick

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

This module of the tcllib data structures 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: