Adds new branches to a node of a tree.

### No options

### Parameters

`TREE` = trees |
Trees to be extended |
---|---|

`NODE` = scalars |
Node at which to extend each tree |

`NBRANCHES` = scalars |
Number of branches to add to each node; default 2 |

`POSITION` = scalars |
Position at which to add the branches to each node; default `*` i.e. after all the current braches from the node |

`NEWNODES` = variates |
Returns the number(s) allocated to the new nodes |

### Description

`BGROW`

provides the basic tree utility of adding new branches at a node, which is used for example by the `BCONSTRUCT`

procedure. Other tree utilities are described in the description of the `TREE`

directive (which declares and initializes a tree).

The tree to be extended is specified by the `TREE`

parameter, and the `NODE`

parameter indicates the node at which the new branches are to be added. The `NBRANCHES`

parameter specifies the number of branches to add. The `POSITION`

specifies where to add them if the node is a non-terminal node; by default they are added after all the branches currently from the node. The `NEWNODES`

parameter saves a variate containing the numbers of the new nodes (i.e. the terminal nodes at the ends of the new branches).

Options: none.

Parameters: `TREE`

, `NODE`

, `NBRANCHES`

, `POSITION`

, `NEWNODES`

.

### See also

Directives: `BASSESS`

, `BCUT`

, `BJOIN`

, `TREE`

.

Procedures: `BCONSTRUCT`

, `BCLASSIFICATION`

, `BGRAPH`

, `BKEY`

, `BPRINT`

, `BPRUNE`

.

Functions: `BBELOW`

, `BBRANCHES`

, `BDEPTH`

, `BMAXNODE`

, `BNBRANCHES`

, `BNEXT`

, `BNNODES`

, `BPATH`

, `BPREVIOUS`

, `BSCAN`

, `BTERMINAL`

.

Commands for: Calculations and manipulation.

### Example

" Examples 1:4.12.3, 1:4.12.4 & 1:4.12.5 " " Declare the original tree." TREE T " Define texts to use as labels for the nodes." TEXT Lab[1...26]; VALUES=\ 'a','b','c','d','e','f','g','h','i','j','k','l','m',\ 'n','o','p','q','r','s','t','u','v','w','x','y','z' " Define information at root to be a pointer with a single element called 'label'." POINTER [NVALUES=!t(label)] T[1] " Set that element to the first value of Lab, i.e. 'a'." TEXT T[1]['label']; VALUE=Lab[1] " Display the tree - first with labels of nodes, then with numbers." BPRINT [PRINT=labelleddiagram,numbereddiagram] T " Extend the tree by forming 3 branches from node 1 (root)." BGROW T; NODE=1; NBRANCH=3; NEWNODES=Gnew " Define the information for the new nodes." POINTER [NVALUES=!t(label)] T[#Gnew] TEXT T[#Gnew]['label']; VALUE=Lab[#Gnew] " Display the extended tree." BPRINT [PRINT=labelleddiagram,numbereddiagram] T " Find the node number of the first terminal node " CALCULATE N1 = BTERMINAL(T; 0) " and then the second terminal node." CALCULATE N2 = BTERMINAL(T; N1) PRINT N1,N2; DECIMALS=0 " Extend the tree by adding 2 branches at the second and then the first terminal node." BGROW T; NODE=N2; NBRANCH=2; NEWNODES=Gnew2 " Define the information for the new nodes." POINTER [NVALUES=!t(label)] T[#Gnew2] TEXT T[#Gnew2]['label']; VALUE=Lab[#Gnew2] BGROW T; NODE=N1; NBRANCH=2; NEWNODES=Gnew1 POINTER [NVALUES=!t(label)] T[#Gnew1] TEXT T[#Gnew1]['label']; VALUE=Lab[#Gnew1] " Display the extended tree." BPRINT [PRINT=labelleddiagram,numbereddiagram] T "4.12.4 Remove the branches below N2, saving these as tree T2; also save and print the node mapping variates." BCUT T; NODE=N2; CUTTREE=T2; OLDNODES=Oldn;\ NEWNODES=Newn; CUTNODES=Cutn PRINT [ORIENT=across] Oldn,Newn,Cutn; FIELD=3; DECIMALS=0 " Display the modified tree, and the cut-tree." BPRINT [PRINT=labelleddiagram,numbereddiagram] T,T2 " Redefine the root of the cut tree so that it no longer shares the same information pointer as the node where the cut was made in the original tree." POINTER [NVALUES=!t(label)] T2root TEXT T2root['label']; VALUE='t2root' ASSIGN T2root; T2; 1 BPRINT [PRINT=labelleddiagram] T2 " Use BCUT to form T3 as a duplicate of T but with renumbered nodes." BCUT [RENUMBER=yes] T; NEWTREE=T3 BPRINT [PRINT=labelleddiagram,numbereddiagram] T3 "4.12.5 Join tree T2 onto node 4 of T3; save and print the numbers of the joined nodes in the revised tree." BJOIN T3; NODE=4; JOINTREE=T2; NEWNODES=Jnew BPRINT [PRINT=labelleddiagram,numbereddiagram] T3 PRINT Jnew; DECIMALS=0 " Tree functions: all nodes below node 2," CALCULATE Below = BBELOW(T3; 0; 0) PRINT Below; DECIMALS=0 " all terminal nodes below node 2," CALCULATE Below0 = BBELOW(T3; 0; 0) PRINT Below0; DECIMALS=0 " first three terminal nodes," CALCULATE N1 = BTERMINAL(T3; 0) & N2 = BTERMINAL(T3; N1) & N3 = BTERMINAL(T3; N2) PRINT N1,N2,N3; DECIMALS=0 " nodes and branches on path to N3," CALCULATE Pn3 = BPATH(T3; N3) & Ln3 = BBRANCHES(T3; N3) PRINT Pn3,Ln3; DECIMALS=0 " depth and number of branches at node 2," CALCULATE Nn2 = BNBRANCHES(T3; 2) & Dn2 = BDEPTH(T3; 2) PRINT Nn2,Dn2; DECIMALS=0 " next nodes on branches 1-3 from node 1, and branch 1 from node 2." PRINT BNEXT(T3; 1; 1); DECIMALS=0 PRINT BNEXT(T3; 1; 2); DECIMALS=0 PRINT BNEXT(T3; 1; 3); DECIMALS=0 PRINT BNEXT(T3; 2; 1); DECIMALS=0 " Scan the tree, taking the nodes in standard order." SCALAR Scan[0]; value=0 CALCULATE Scan[1] = BSCAN(T3; Scan[0]) & Scan[2] = BSCAN(T3; Scan[1]) & Scan[3] = BSCAN(T3; Scan[2]) & Scan[4] = BSCAN(T3; Scan[3]) & Scan[5] = BSCAN(T3; Scan[4]) & Scan[6] = BSCAN(T3; Scan[5]) & Scan[7] = BSCAN(T3; Scan[6]) & Scan[8] = BSCAN(T3; Scan[7]) & Scan[9] = BSCAN(T3; Scan[8]) PRINT Scan[1...9]; FIELD=8; DECIMALS=0