Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.DIAGRAM.TREE-TO-DIAGRAM

This package generates a Diagram! text file drawing a tree. The tree drawn is a list whose car is the node displayed, and whose cdr is the list of children. License: AGPL3 Copyright Pascal J. Bourguignon 1994 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>

README:

FUNCTION

Public

TREE-DEPTH (TREE)

PRE: tree is a cons of the node and the list of children. RETURN: the depth of the tree.

TREE-GENERATE-RANDOM (DEPTH WIDTH)

RETURN: A random tree with random number as node, of maximal depth `depth' and where each node has a maximum of `width` children. NOTE: The result can easily be degenreate (a single node, or a much smaller tree).

TREE-SIZE (TREE)

PRE: tree is a cons of the node and the list of children. RETURN: The size of the tree (number of nodes)

TREE-TO-DIAGRAM (TREE)

PRE: tree is a cons of the node and the list of children. DOES: writes to the *standard-output* the Diagram file text.

Private

TREE-DIAGRAM-GENERATE-ADJUST-X (INC)

PRIVATE. inc: a list (n l x y) corresponding to the after last brother. RETURN: a list (n' l' x' y') for the next uncle node.

TREE-DIAGRAM-GENERATE-INHERIT (N L X Y)

PRIVATE. DOES: Generates the Diagram text for a 'inherit' symbol (vertical triangle). n: the Diagram symbol number (may be used in Diagram links). l: the Diagram layer. x,y: the coordinates. RETURN: a list (n' l' x' y') for the first child node.

TREE-DIAGRAM-GENERATE-NODE (N L X Y NODE)

PRIVATE. DOES: Generates the Diagram text for a node. n: the Diagram symbol number (may be used in Diagram links). l: the Diagram layer. x,y: the coordinates. node: the text in the node rectangle. RETURN: a list (n' l' x' y') for the following brother node.

TREE-DIAGRAM-GENERATE-TREE (N L X Y TREE)

PRIVATE. DOES: writes to the *standard-output* the Diagram text for the subtree 'tree'. RETURN: a list (n' l' x' y') for the next brother subtree.