TREEP

Prints a binary tree.

Required Arguments

ICLSON — Vector of length NODE – 1 containing the left son nodes. (Input)
Node number NODE + K has left son given by ICLSON(K) for K = 1, NODE   1.

ICRSON — Vector of length NODE – 1 containing the right son nodes. (Input)
Node number NODE + K has right son given by ICRSON(K) for K = 1, NODE   1.

CLEVEL — Vector of length NODE   1 containing the level used in merging or splitting the son nodes. (Input)
CLEVEL(K) specifies the scale to be used on the vertical (IMETH = 1 or 2) or horizontal (IMETH = 3) axis for node NODE + K, for K = 1, 2, NODE  1.

NSCALE — Number of horizontal slices of tree. (Input)
NSCALE must be positive.

SCALE — Vector of length two giving the interval on the CLEVEL axis which should be used to plot the tree. (Input)
SCALE(1) is the location for printing the terminal nodes. The root node is printed at SCALE(2).

NODENMCHARACTER*(*) vector of length NODE containing the terminal node labels. (Input)
If terminal node labels are to be 1, 2, 3, , then NODENM(1) should be “DEFAULT” and the remaining elements of NODENM are not used. The length of each label is M, where M is determined by the user.

Optional Arguments

NODE — Initial number of observations or nodes. (Input)
NODE must be greater than 2.
Default: NODE = size (ICLSON,1) + 1.

IMETH — Method to be used for printing the binary tree. (Input)
Default: IMETH = 1.

 

IMETH

Method

1

Horizontal tree

2

Horizontal I‑tree

3

Vertical tree

IROOT — Subtree specification. (Input)
IROOT specifies the root node of the subtree to be printed. If IROOT = 2 * NODE   1 (or zero for the default), the entire tree is printed. IROOT must be in the range NODE + 1 to 2 * NODE  1.
Default: IROOT = 0.

NFILL — The number of filler lines printed between horizontal or vertical node lines. (Input)
NFILL = 1 is usually sufficient. NFILL must be nonnegative.
Default: NFILL = 1.

FORTRAN 90 Interface

Generic: CALL TREEP (ICLSON, ICRSON, CLEVEL, NSCALE, SCALE, NODENM [])

Specific: The specific interface names are S_TREEP and D_TREEP.

FORTRAN 77 Interface

Single: CALL TREEP (NODE, ICLSON, ICRSON, IMETH, CLEVEL, IROOT, NSCALE, NFILL, SCALE, NODENM)

Double: The double precision name is DTREEP.

Description

Routine TREEP prints a binary tree which may represent results of hierarchical clustering algorithm such as the routine CLINK.

Let M = NODE indicate the number of nodes. A binary tree is composed of M terminal nodes and M  1 nonterminal nodes uniquely numbered 1 to M and M + 1 to M + (M  1), respectively. Each nonterminal node joins together two son nodes which may or may not be terminal. Nonterminal nodes M + K are printed on the vertical scale interval [S1S2] at the level given in CK, for K = 1, 2, M  1, where S1 = SCALE(1), S2 = SCALE(2), and CK = CLEVEL(K).

Comments

1. Workspace may be explicitly provided, if desired, by use of T2EEP/DT2EEP. The reference is:

CALL T2EEP (NODE, ICLSON, ICRSON, IMETH, CLEVEL, IROOT, NSCALE, NFILL, SCALE, NODENM, IDTREE, ISTREE, IOTREE, INTREE, TLTREE)

The additional arguments are as follows:

IDTREE — Work vector of length IROOT. IDTREE is used to store the distance of each node from the vertical axis in vertical tree.

ISTREE — Work vector of length IROOT used to store all the nodes. IROOT is the first element of the array.

IOTREE — Work vector of length IROOT + 1 used to store the index of each node as TLTREE is sorted.

INTREE — Work vector of length IROOT.

TLTREE — Work vector of length IROOT + 1 used to store the level of each node in descending order in a vertical tree. It is used to store the distance of each node from the top of the horizontal line in ascending order in a horizontal tree.

2. Printing starts on a new page with default page width 78. The user may change it by calling the routine PGOPT in advance.

Example

 

USE PGOPT_INT

USE TREEP_INT

USE UMACH_INT

 

IMPLICIT NONE

INTEGER NODE

PARAMETER (NODE=5)

!

INTEGER ICLSON(NODE-1), ICRSON(NODE-1), IMETH, IPAGE, NOUT, NSCALE

REAL CLEVEL(NODE-1), SCALE(2)

CHARACTER NODENM(NODE)*7

!

DATA ICLSON/5, 6, 4, 7/

DATA ICRSON/3, 1, 2, 8/

DATA NODENM/'DEFAULT', ' ', ' ', ' ', ' '/

DATA CLEVEL/1., 2., 3., 4./

DATA SCALE/0., 5./

! Set page width

IPAGE = 70

CALL PGOPT (-1, IPAGE)

NSCALE = 1

! Horizontal tree

IMETH = 1

CALL TREEP (ICLSON, ICRSON, CLEVEL, NSCALE, SCALE, NODENM, &

IMETH=IMETH)

CALL UMACH (2, NOUT)

WRITE (NOUT,99999)

99999 FORMAT (1X, //////)

! Horizontal I-tree

IMETH = 2

CALL TREEP (ICLSON, ICRSON, CLEVEL, NSCALE, SCALE, NODENM, &

IMETH=IMETH)

!

END

Output

 

Similarity range from 0. to 5.000000

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

5*************

*

6*************

* *

3************* *

*

7**************************

* *

1************************** *

*

9**************

*

4*************************************** *

* *

8*************

*

2***************************************

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

Similarity range from 0. to 5.000000

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

5************6************7*************************9**************

* * *

3************* * *

* *

1************************** *

*

4**************************************8*************

*

2***************************************

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++