## This is an example of using bases to speed up calculation of topological properties.
## Creates a tree
tree <- rtree4(50)
## Sets up the list of bases
baseFuncs <- c(ladderNums, treeImb, nTipDescendants)
## Creates the base
base <- baseCreate(tree,baseFuncs)
## Sets up the list of functions from the base
## Note that the functions are matched with the correct base element
topFuncs <- c(fNLadders,fColless,function(x) {fNConfig(x,2)})
## Finds the topological properties
baseAnalysis(base,topFuncs)
## Now a new list of topFuncs
## Some of these use the same elements of the base
## This means that there will be a speed improvement
topFuncs2 <- c(topFuncs, function(x) {fNConfig(x,3)},fAvgLadder)
## Now we must create an appropriate base for these topFuncs
## Note that the elements are matched to those of topFuncs
base2 <- c(base,base[3],base[1])
## And the new topological properties
baseAnalysis(base2,topFuncs2)
Run the code above in your browser using DataLab