public void init ( LblTree t1 , LblTree t2 ) { LabelDictionary ld = new LabelDictionary ( ) ; it1 = new InfoTree ( t1 , ld ) ; it2 = new InfoTree ( t2 , ld ) ; size1 = it1 . getSize ( ) ; size2 = it2 . getSize ( ) ; IJ = new int [ Math . max ( size1 , size2 ) ] [ Math . max ( size1 , size2 ) ] ; delta = new double [ size1 ] [ size2 ] ; deltaBit = new byte [ size1 ] [ size2 ] ; costV = new long [ 3 ] [ size1 ] [ size2 ] ; costW = new long [ 3 ] [ size2 ] ; // Calculate delta between every leaf in G (empty tree) and all the nodes in F. // Calculate it both sides: leafs of F and nodes of G & leafs of G and nodes of // F. int [ ] labels1 = it1 . getInfoArray ( POST2_LABEL ) ; int [ ] labels2 = it2 . getInfoArray ( POST2_LABEL ) ; int [ ] sizes1 = it1 . getInfoArray ( POST2_SIZE ) ; int [ ] sizes2 = it2 . getInfoArray ( POST2_SIZE ) ; for ( int x = 0 ; x < sizes1 . length ; x ++ ) { // for all nodes of initially left tree for ( int y = 0 ; y < sizes2 . length ; y ++ ) { // for all nodes of initially right tree // This is an attempt for distances of single-node subtree and anything alse // The differences between pairs of labels are stored if ( labels1 [ x ] == labels2 [ y ] ) { deltaBit [ x ] [ y ] = 0 ; } else { deltaBit [ x ] [ y ] = 1 ; // if this set, the labels differ, cost of relabeling is set // to costMatch } if ( sizes1 [ x ] == 1 && sizes2 [ y ] == 1 ) { // both nodes are leafs delta [ x ] [ y ] = 0 ; } else { if ( sizes1 [ x ] == 1 ) { delta [ x ] [ y ] = sizes2 [ y ] - 1 ; } if ( sizes2 [ y ] == 1 ) { delta [ x ] [ y ] = sizes1 [ x ] - 1 ; } } } } }
Initialization method .