| filterANLid {xegaDerivationTrees} | R Documentation |
Filter an Attributed Node List (ANL) of a derivation tree by a symbol identifier.
Description
filterANLid() deletes all nodes whose node$ID does not match
node$ID.
If the resulting list is empty, a list of length 0 is returned.
Usage
filterANLid(ANL, nodeID = 1)
Arguments
ANL |
Attributed node list. |
nodeID |
Integer. The identifier of a symbol. |
Details
An attributed node has the following elements:
-
$ID: Id in the symbol tableST. -
$NT: Is the symbol a non-terminal? -
$Pos: Position in the trail. -
$Depth: Depth of node. -
$RDepth: Residual depth for expansion. -
$subtreedepth: Depth of subtree starting here. -
$Index: R index of the node in the derivation tree. Allows fast tree extraction and insertion.
For the implementation of crossover and mutation, we expect a non-terminal symbol identifier.
Value
An attributed node list with nodes whose depths are in
minb:maxb.
Each node is represented as a list of the following attributes:
-
Node$ID: Id in the symbol table ST. -
Node$NT: Is the symbol a non-terminal? -
Node$Pos: Position in the trail. -
Node$Depth: Depth of node. -
Node$RDepth: Residual depth for expansion. -
Node$subtreedepth: Depth of subtree starting here. -
Node$Index: R index of the node in the derivation tree. Allows fast tree extraction and insertion.
See Also
Other Access Tree Parts:
filterANL(),
treeANL(),
treeChildren(),
treeRoot()
Examples
g<-compileBNF(booleanGrammar())
set.seed(111)
a<-randomDerivationTree(g$Start, g, maxdepth=10)
b<-treeANL(a, g$ST)
c<-filterANLid(b, nodeID=5)
d<-filterANLid(b, nodeID=6)
e<-filterANLid(b, nodeID=7)
f<-filterANLid(b, nodeID=8)