# CompareTrees: Compare two tree structures In erhcv: Equi-Rank Hierarchical Clustering Validation

## Description

Provide a logical answer to the question "Are two trees equivalent?".

## Usage

 `1` ```CompareTrees(tree_test, tree_ref) ```

## Arguments

 `tree_test` (testing tree) a tree structure in the form of nested lists (as the output of hclust2tree, for example) `tree_ref` (reference tree) a tree structure in the form of nested lists (as the output of hclust2tree, for example)

## Details

This test is particularly useful when two trees are not ordered in the same way. As the structure are lists, one could argue that this function is a modification of the `identical` base function, overcoming the ordering.

## Value

boolean: TRUE implies that the two trees are equivalent.

## Author(s)

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17``` ```## Comparison between "identical" and "compareTrees" ## ## The trees are "identical" tree1 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 2, 1) tree2 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 2, 1) CompareTrees(tree1, tree2) identical(tree1, tree2) ## The trees are "equivalent" (notice the leaves 1 and 2 interchanged) tree1 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 2, 1) tree2 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 1, 2) CompareTrees(tree1, tree2) identical(tree1, tree2) ```