fn eq_helper(tree_1_idx: NodeIndex, tree_1: &Tree, tree_2_idx: NodeIndex, tree_2: &Tree) -> bool {
    let mut nodes1 = tree_1.children(tree_1_idx).collect::<Vec<_>>();
    tree_1.sort_indices(&mut nodes1);
    let mut nodes2 = tree_2.children(tree_2_idx).collect::<Vec<_>>();
    tree_2.sort_indices(&mut nodes2);

    for (node1, node2) in nodes1.into_iter().zip(nodes2) {
        if tree_1[node1] != tree_2[node2] {
            return false;
        }
        let p1 = tree_1
            .parent(node1)
            .map(|(parent_id, edge_id)| (&tree_1[parent_id], &tree_1[edge_id]));
        let p2 = tree_2
            .parent(node2)
            .map(|(parent_id, edge_id)| (&tree_2[parent_id], &tree_2[edge_id]));
        if p1 != p2 {
            return false;
        }

        if !eq_helper(node1, tree_1, node2, tree_2) {
            return false;
        }
    }
    true
}
// recursively check if at each level the trees are identical.
recursively check if at each level the trees are identical.
recursively check if at each level the trees are identical .
fn eq_helper(tree_1_idx: NodeIndex, tree_1: &Tree, tree_2_idx: NodeIndex, tree_2: &Tree) -> bool {
    let mut nodes1 = tree_1.children(tree_1_idx).collect::<Vec<_>>();
    tree_1.sort_indices(&mut nodes1);
    let mut nodes2 = tree_2.children(tree_2_idx).collect::<Vec<_>>();
    tree_2.sort_indices(&mut nodes2);
    for (node1, node2) in nodes1.into_iter().zip(nodes2) {
        if tree_1[node1] != tree_2[node2] {
            return false;
        }
        let p1 = tree_1
            .parent(node1)
            .map(|(parent_id, edge_id)| (&tree_1[parent_id], &tree_1[edge_id]));
        let p2 = tree_2
            .parent(node2)
            .map(|(parent_id, edge_id)| (&tree_2[parent_id], &tree_2[edge_id]));
        if p1 != p2 {
            return false;
        }
        if !eq_helper(node1, tree_1, node2, tree_2) {
            return false;
        }
    }
    true
}
fn eq_helper ( tree_1_idx : NodeIndex , tree_1 : & Tree , tree_2_idx : NodeIndex , tree_2 : & Tree ) -> bool { let mut nodes1 = tree_1 . children ( tree_1_idx ) . collect :: < Vec < _ > > ( ) ; tree_1 . sort_indices ( & mut nodes1 ) ; let mut nodes2 = tree_2 . children ( tree_2_idx ) . collect :: < Vec < _ > > ( ) ; tree_2 . sort_indices ( & mut nodes2 ) ; for ( node1 , node2 ) in nodes1 . into_iter ( ) . zip ( nodes2 ) { if tree_1 [ node1 ] != tree_2 [ node2 ] { return false ; } let p1 = tree_1 . parent ( node1 ) . map ( | ( parent_id , edge_id ) | ( & tree_1 [ parent_id ] , & tree_1 [ edge_id ] ) ) ; let p2 = tree_2 . parent ( node2 ) . map ( | ( parent_id , edge_id ) | ( & tree_2 [ parent_id ] , & tree_2 [ edge_id ] ) ) ; if p1 != p2 { return false ; } if ! eq_helper ( node1 , tree_1 , node2 , tree_2 ) { return false ; } } true }
recursively check if at each level the trees are identical.
recursively check if at each level the trees are identical .
tree_1_idx
NodeIndex
tree_1
&Tree
tree_2_idx
NodeIndex
tree_2
&Tree
tree_1_idx
NodeIndex
tree_1
&Tree
tree_2_idx
NodeIndex
tree_2
&Tree