tree

Class summary
tree
tree-node
Method summary
add-node tree node &key &allow-other-keys
all-children node &key key
children tree-node
copy-object-content (source tree-node) (destination tree-node)
copy-object-content (source tree) (destination tree)
cut-node tree node
depth node
empty? container
find-node tree node &key key test &allow-other-keys
id tree-node
insert-node tree node &optional parent
leaf? node
leafs tree
make-s-dot object &key &allow-other-keys
nodes tree
parent tree-node
parents node &key key
replace-node tree old-node new-node
string-for-s-dot object &key &allow-other-keys
top tree
top? node
traverse tree func &key &allow-other-keys
Function summary
mkdotstr symbol
tree-node    [Class]

A node is a very general object. When a class subclasses from a node all it means is that it can be maintained in a tree structure.

:id    [Initarg]
:parent    [Initarg]
:children    [Initarg]
id    [Slot]

Needed for drawing. You can overwrite them as long as each node has a unique ID.

children   tree-node  [Generic function]

Returns and (with setf) changes the children of the specified tree-node

parent   tree-node  [Generic function]

Returns and (with setf) changes the parent of the specified tree-node

id   tree-node  [Generic function]

Returns and (with setf) changes the id of the specified tree-node

tree    [Class]

A basic tree keeping all the nodes and a reference to the top.

:nodes    [Initarg]
:top    [Initarg]
top   tree  [Generic function]

Returns and (with setf) changes the top of the specified tree

nodes   tree  [Generic function]

Returns and (with setf) changes the nodes of the specified tree

top?   node  [Generic function]

Returns true if the node is the top of the tree.

empty?   container  [Generic function]

Returns true if the container is empty.

traverse   tree func &key &allow-other-keys  [Generic function]

Traverses the tree and evaluates the function for every node. The key parameter from allows you to specify another start-node than the top of the tree. The traversal is depth-first.

leaf?   node  [Generic function]

Returns true if the node is a leaf

leafs   tree  [Generic function]

Returns all the leafs of the tree.

find-node   tree node &key key test &allow-other-keys  [Generic function]

Finds the node based on the given key and test in the tree. If not found returns nil.

add-node   tree node &key &allow-other-keys  [Generic function]

Adds the given node to the tree. It can only allow adding under existing nodes. This means that the first element added has to be the top.

replace-node   tree old-node new-node  [Generic function]

replaces the old-node by the new-node in the tree. It only works when old-node is a leaf.

cut-node   tree node  [Generic function]

Destructively cuts the node from the tree. Returns the tree if successful, nil if the top node is cut.

insert-node   tree node &optional parent  [Generic function]

Inserts node in tree at where.

depth   node  [Generic function]

Returns the depth of a certain node (eg. the number of parent nodes to the top of the tree).

parents   node &key key  [Generic function]

Traverses the branch of the given node upwards and returns these elements in a list (i.e. its parents). The first element will be the top (root).

all-children   node &key key  [Generic function]

Traverses the branch of the given node downwards and returns these elements in a list (i.e. all its children).

string-for-s-dot   object &key &allow-other-keys  [Generic function]

Should return a short string (one word) for the object so that it fits in a node for exporting to dot.

make-s-dot   object &key &allow-other-keys  [Generic function]

Should return a valid s-dot expression for the object. If in doubt use s-dot:check-syntax function.

copy-object-content   (source tree-node) (destination tree-node)  [Method]
copy-object-content   (source tree) (destination tree)  [Method]
mkdotstr   symbol  [Function]

Dot cannot handle - in strings so it just replaces all - by _. It is best to call this function on each symbol or string you pass to dot.