src/GRAPHGEN/tree2dag_identities.cpp
// Search in tree n2 there is a subtree equal to n1, which is not n1
Search in tree n2 there is a subtree equal to n1, which is not n1
Search in tree n2 there is a subtree equal to n1 which is not n1
void FindAndLinkIdentiesRec(BinaryDrag<conact>::node* n1, BinaryDrag<conact>::node* n2) {
    if (n2->isleaf() || n1 == n2)
        return;
    if (n1 != n2->left && EqualTrees(n1, n2->left)) {
        n2->left = n1;
    }
    if (n1 != n2->right && EqualTrees(n1, n2->right)) {
        n2->right = n1;
    }
    FindAndLinkIdentiesRec(n1, n2->left);
    FindAndLinkIdentiesRec(n1, n2->right);
}
void FindAndLinkIdentiesRec ( BinaryDrag < conact > :: node * n1 , BinaryDrag < conact > :: node * n2 ) { if ( n2 -> isleaf ( ) || n1 == n2 ) return ; if ( n1 != n2 -> left && EqualTrees ( n1 , n2 -> left ) ) { n2 -> left = n1 ; } if ( n1 != n2 -> right && EqualTrees ( n1 , n2 -> right ) ) { n2 -> right = n1 ; } FindAndLinkIdentiesRec ( n1 , n2 -> left ) ; FindAndLinkIdentiesRec ( n1 , n2 -> right ) ; }
Search in tree n2 there is a subtree equal to n1, which is not n1
Search in tree n2 there is a subtree equal to n1 which is not n1