data(geospiza)
## Return labels from geospiza
tipLabels(geospiza)
## Internal node labels in geospiza are empty
nodeLabels(geospiza)
## Creating internal node labels
ndLbl <- paste("n", 1:nNodes(geospiza), sep="")
nodeLabels(geospiza) <- ndLbl
nodeLabels(geospiza)
## naming the labels
names(ndLbl) <- nodeId(geospiza, "internal")
## shuffling the labels
(ndLbl <- sample(ndLbl))
## by default, the labels are attributed in the order
## they are given:
nodeLabels(geospiza) <- ndLbl
nodeLabels(geospiza)
## but use.names puts them in the correct order
labels(geospiza, "internal", use.names=TRUE) <- ndLbl
nodeLabels(geospiza)
Run the code above in your browser using DataLab